March 22, 2008

Http file upload with a progress bar indicator

I was looking for a solution for uploading a file through a web browser with a progress bar indicator. First I was thinking about AJAX with PHP. Unfortunately it looks like PHP does not provide any information about the file which is just being uploaded. So most of the AJAX solutions are based on different CGI scripts.

I was almost ready to give it up, when I found a brilliant solution: Flash!

Flash has more programming possibilities than JavaScript and AJAX. And what's more, new Flash versions have support for external calls and events handling via JavaScript! So you can include into your web page a flash object and control it through JavaScript calls which can be bound to buttons or any other HTML object. There are even frameworks which are combining AJAX and Flash together :)

image SWFUpload is a Flash object for uploading files to a web server. As it was said above, it has support for events handling through JavaScript and can be used to create a fancy and eye-candy file uploader with progress bar indicator. And the best thing is that you don't have to change almost nothing on your server side. The same scripts, the same features.

Demos.