简体   繁体   English

用scp / sftp格式选择传输文件

[英]transfer file selected in form with scp/sftp

I'd like to upload file from html form through scp/sftp (I know their syntax) in php script, not the traditional way (upload to server's /tmp folder, then calling move_uploaded_file ) . 我想通过php脚本中的scp / sftp(我知道它们的语法)从html表单上传文件,而不是传统方式(上传到服务器的/ tmp文件夹,然后调用move_uploaded_file )。 Upon submitting the form, I'd just like to fetch the uploaded file's full path from <input type="file"...> and pass it into ssh2_scp_send . 提交表单后,我只想从<input type="file"...>获取上载文件的完整路径,并将其传递到ssh2_scp_send

If there is a way please let me know, if not, please explain why. 如果有办法,请告诉我,如果没有,请解释原因。

Btw, if there is a way to select in web page where the user wants to upload the file on server (some gui/dialog), let me know too. 顺便说一句,如果有一种方法可以在网页中选择用户要在服务器上上传文件的方式(一些gui / dialog),也请告诉我。 Thanks. 谢谢。

You need to separate the server side from the client side. 您需要将服务器端与客户端分开。 The web page (client side) is generally not able to upload anything anywhere directly (without use of some plugin or applet - Java applet would work fine). 网页(客户端)通常无法直接在任何地方上传任何内容(无需使用某些插件或applet-Java applet可以正常工作)。 PHP itself, being a server-side language (in general, I am ignoring border cases now) can't be used to directly transfer the file from user's computer to some SFTP server. PHP本身是一种服务器端语言(通常,我现在忽略了边框),不能用于将文件从用户计算机直接传输到某些SFTP服务器。

So the best option is to let the user upload the file to the HTTP server as a part of the form, then upload the received file to the SFTP server. 因此,最好的选择是让用户将文件作为表单的一部分上传到HTTP服务器,然后将接收到的文件上传到SFTP服务器。 If you can't do this (eg. due to size limitations), you can create a Java applet which will let the user choose the file and transfer it to the server. 如果您不能执行此操作(例如,由于大小限制),则可以创建Java小程序,该Java小程序将允许用户选择文件并将其传输到服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM