Monday, March 13th, 2006
Thomas Larsson has posted a short tutorial on his blog with something that I’ve heard many a PHP (and just web) developer looking for – a good way to provide multiple file uploads without sacrificing the functionality of the page. Thomas has created a combination of PHP, Ajax, and a backend script to create a method for asynchronous file uploads complete with a progress bar.
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.
He notes that there are two ways around this situation – a patch from Pdoru that has to be applied directly to the PHP install or his method – calling a remote page via an iframe to handle the upload itself. The script sends off the data from the upload form to this other script via the iframe (XMLHttpRequest doesn’t support file uploads) and the Prototype library comined with a PHP script check the file’s upload status and advance the progress bar along.
Of course, the complete code is posted and he even includes links to other sites with other multiple file upload methods as well. He also notes that there are some limitations and possible issues between browsers for the script that he just hasn’t gotten to test with yet.
Posted by Chris Cornutt at 8:36 am