Asynchronous file upload with AJAX progress bar in PHP
Filed Under (Tutorials) by admin on 13-03-2006
Tomas Larsson over at tomas.epineer.se has posted a tutorial on uploading files with PHP and showing the progress with Ajax. This is a relatively short and easy tutorial and adds that little extra to your uploading forms.
One of the few things that I find lacking in PHP is the ability to report the progress of a file upload. This means that file uploads, especially uploads of larger files, can be extremely frustrating for end users when they don’t know if the upload is progressing or if it has stalled or if it has even started. There are two ways around this. One is to patch PHP, Pdoru provides such a patch. Not everyone can patch PHP though. You can’t use a patch if you’re on a shared server, if you want to use ready-made binaries, if you don’t want to risk stability by using a patch or if you just don’t want to have to remember to apply the patch again every time you upgrade PHP. The other option is to use a perl script to receive the file when it’s uploaded. This is the approach used by MegaUpload. MegaUpload is what I have based my solution on, but I have added asynchronous file upload support and an AJAX upload progress bar, instead of the refreshing popup used by MegaUpload.










Great job guys…
Very Very nice information here… Thanks
I have written another script, loosely based on the work above, dealing with my frustrations of getting the script to work. You can get it for completely free at http://www.seemysites.net/projFolder/uploader
Not sure that patching PHP will be a good solution. What if user does not have such ability (virtual/shared hosting)? Better to use Perl, like we did: http://www.sibsoft.net/xupload.html
Maybe PHP will be released with such ability (accessing raw post data) soon?