简体   繁体   中英

Upload local file from webbrowser directly to FTP server, bypass the web server

I want to upload user uploaded file (from website <form> ) to my FTP server, in which I want to bypass the server and want that file should be sent to FTP server directly. Is it possible using PHP or JavaScript?

In current scenario when I upload file using HTML form and PHP to Apache server, the file is stored in /tmp/ directory and then I can transfer it to FTP location. But this takes double time in uploading as the filed is first uploaded to Apache server and then to the FTP server.

Cloud servers run this way, where Apache server can be by passed and file can be posted directly to cloud server)

I want this so that we can overcome the HTTP part and want to upload large file to FTP server without getting any HTTP upload restrictions.

The HTML form tag does not support the FTP.


You cannot use PHP either as it cannot access local (as of webbrowser) files.


So JavaScript is the only likely solution.

The XMLHttpRequest class theoretically supports FTP:

Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including file and ftp ).

But in reality it probably does not.
See the accepted answer to What is the syntax to do a cross-domain XMLHTTPREQUEST to an FTP server?

So actually, there does not seem to be any solution readily available.


If possible, run a web server on the FTP server host and send the files using the web server (HTTP).


Another alternative is to stick with the transferring via your web server, but in a streaming mode. Post your file to the web server. Make the handling script continuously read the incoming data and have them continuously uploaded to the FTP server.

You won't save a bandwidth, but you will save time (as both transfers happen nearly in parallel).

Using the ftp_fput with a handle to the standard input should do (didn't try).

its very difficult to FTP data(BIGfile) to backup server without using HTTP protocol in a web application.

Lets say, S1-( Client Browser ), S2-(code container server), S3-(Files Backup server) and we want to upload 2gb file from s1 using FTP.

use case diagram This can be done by "JavaApplet" . we can embed uploader applet in webapplication. This applet will run inside browser sand box. go through link sample code for ftp using applet

provided you have to enable java on your browser. sample code

ftp block diagram for side load

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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