FTP upload with PHP

Hi there

We are hosting a web server that requires large files (100MB+) to be uploaded to it. We are using PHP upload scripts, and it is working, but we are getting complaints that the uploads are unreliable (some files fail to upload, with no error messages).

I have been reading on various forums that FTP should rather be used for larger files, rather than HTTP. But from what I can see, there are some limitations, and I was wondering if there are any ways around these:

  • Using cURL would mean that the files would first be uploaded to a temp folder on the web server via HTTP, and then only sent via FTP. This defeats the purpose, because if it is already on the Web Server (which is hosted locally), then I might just as well move the file.
  • Using the built in FTP functionality of PHP, it appears that ones needs to know the full path of the source file. The users who are uploading files are accessing the Web server via a form in a browser, which will not give the PHP script the full path of the file to be uploaded.

All we want is to have a reliable means for an end-user to access a site with a browser, fill in a form, choose a file to upload, and submit it. Additional functionality, like a progress bar, the ability to select multiple files and a resume option for failed uploads, would all be very nice. But the main concern is that the transfers be more reliable.

Thanks for any advice.


I’ve never heard of an ability to upload files to FTP from a web site. Sure, some browsers are FTP-capable but file uploads need to be set up manually by the user, which is mostly the same as if you gave them your FTP credentials and asked to use an FTP client. What you need is a way to make the browser connect to FTP on your site and post uploaded file there - in my opinion there is no way to do that either with html or javascript.

The solution that should work is write a java applet which will be able to connect to FTP from your site and upload the file to the proper folder. That would probably require a signed applet or accepting permissions by the user to access local file system. I think something similar could be done in Flash. Then you would have an additional method for uploading and those who don’t have java (or flash) can still use the standard form.

A quick search gave me some ready made tools: http://jupload.sourceforge.net/

And be sure to create a progress bar for the standard form - the browsers don’t give any hint of the upload progress and it can be perplexing to the users.

Java or Flash based uploaders are definately the way to go here - they run locally to the user’s computer, which will give them the access required to act as an FTP client. Downside is that you’ve got to give out the credentials for your ftp to do this, but small price to pay if you’ve properly set up the FTP server.

A file that size should never be attempted to be pushed via HTTP-Based file transfer.