Blog Posts

Upload Progress Meter extension for PHP 5.2

Showing a real progress bar when uploading large files is an often requested (and quite informative) feature, which is not easily doable with the way the upload handling works in PHP.

There is a patch available for PHP 4.4 and 5.0, which made it nevertheless possible, but some php core files itself needed to be patched for that.

But approx. 2 months ago a similar patch was committed to the PHP_5_2 branch which now makes the patching of PHP unnecessary. You still need an extension for getting the data and that's what I wrote last weekend. It's based on the work of Doru Petrescu, but as the patch is quite different, I started from scratch, but copied some helper functions and the basic idea from Doru's extension.

Here's the code and svnweb.

As this new uploadprogress extension is almost compatible with the one from Doru, you can use his demo files or the ones by Joshua Eichorn described on his blog using the html_AJAX UploadProgressMeter. Just rename the function upload_progress_meter_get_info() to uploadprogress_get_info() in all the files. I made also a little demo available, which should be as simple as possible. The source code is here.

If there's enough interest in the extension, I may try to submit it to PECL. I will also try to add a memcached based mode instead of writing to files.

And as always, use it at your own risk, I didn't test it very thoroughly (especially not at all on windows :) )

Update: It's now finally in PECL: http://pecl.php.net/package/uploadprogress. The latest sources are also available there

Update 2009: If you have problems get it running, see the "common Issues and some answers" blog post and check the new example, which comes with the extension and is also available here.

Related Entries:
- Upload Progress Meter 1.0.1 released
- Upload Progress Meter - Common issues and some answers
- Upload Progress Meter for Windows - The next take
- Upload Progress Meter extension 0.9.2 released
- Upload Progress Meter for Windows

About the author

Comments [188]