The uploadprogress extension is fairly simple to use - but it is important to note that on some PHP configurations it doesn't function correctly and only returns a progress of 100%.

Upload progress screenshot

The JavaScript uses David Stone's method for displaying percentage bars but you can modify the onCreate, onUpdate and onComplete callbacks if you want to use your own.

1) You will need uploadprogress >= 0.3.1 (0.3.0 does not seem to work for me), to build it from source (don't forget to restart your webserver after installing):

                      cvs -d :pserver:cvsread@cvs.php.net:/repository checkout pecl/uploadprogress
cd pecl/uploadprogress && phpize && ./configure && make && sudo make install

2) Progress tracking is automatically enabled if you have a field named UPLOAD_IDENTIFIER with a unique ID in your file upload form:

                      <input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $uploadID; ?>" id="uploadIdentifier" />
                    

3) You retrieve the upload progress with your UPLOAD_IDENTIFIER (obviously these calls will be AJAX requests):

                      $data = uploadprogress_get_info($uploadID);
                    

Once the upload is complete the extension will remove the temporary file and further info calls will return null.

That's it!

See the demo
Download the code