Blog > December 2008

A Useful PHP File Upload Progress Meter

December 2008 · 90 Comments


UPDATE - Click here for a new (better) PHP Upload Progress Bar Script


If you're like me, you want a PHP upload progress meter that is actually useful in your web applications. All of the upload progress meters that I've run across only include the file upload field by itself, which is not realistic in an actual web application situation. You will most likely be entering other information along with uploading a file. The demo is an adaptation this php file upload progress meter.

The demo below will show you how to display a progress upload meter while also entering other information within the same form.

The progress meter will only show if you actually choose a file to upload. If you are just entering information in the text fields, then the progress meter will not show.


Single File Upload


Multiple File Uploads


YUI Code Library

You need this to display the progress meter bar. Look at demo source code for essential JS files.


Requirements:
You must have APC (Alternative PHP Cache) and PHP 5.2 installed on your server for any of this to work.

This is really the only potential problem for those who don't have root access to their server. It's not that difficult to install, but you either have to have root access, or your hosting provider will need to do this for you. The script will definitely not work without this.

Installing APC on your Linux server
Installing APC on your Windows server
Important: Make sure to include apc.rfc1867 = on in your php.ini file after APC is installed. Your php.ini file should be located in the /etc/ directory.


Resources
Upload Progress Meter by Rasmus Lerdorf
This is where the majority of my script came from. In my opinion, this is the best and cleanest php upload progress meter on the web.