I want to upload user uploaded file (from website
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.
form tag does not support the FTP.
You cannot use PHP either as it cannot access local (as of webbrowser) files.
XMLHttpRequest class theoretically supports FTP:
Despite its name,
XMLHttpRequestcan be used to retrieve any type of data, not just XML, and it supports protocols other than HTTP (including
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).
ftp_fput with a handle to the standard input should do (didn't try).