Reputation: 61
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.
Upvotes: 2
Views: 8416
Reputation: 202534
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 (includingfile
andftp
).
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).
Upvotes: 1
Reputation: 1
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
Upvotes: -1