Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Joshua Eichorn's Blog:
AJAX File Upload Progress
May 02, 2005 @ 12:22:34

In continuing with his exploration in the land of PHP+XMLHttpRequest, Joshua Eichorn has a new posting today about a "file upload progress meter" that he's developed with a simple bit of PHP and Javascript.

A couple days ago I found an interesting ruby on rails project. It uses AJAX to update a progress bar as the file uploads. The trick is a patch to rails for getting upload status and doing the upload in an iframe so that the main page is still active.

So to replicate this I just had to find a patch that provides upload status in PHP and then implment my little iframe upload widget. I found the PHP with a little work from google: Upload Progress Meter.

The basic idea is that the page, with a form, has a hidden iframe, a hidden "progress" div, and some javascript. Upload the file (the form's target is the iframe) and it builds out the progress div based on the results of an update function run every second. This makes the query to the server for the percent uploaded and returns it to the page.

Not exactly the simplest way to do it, but it's definitely a start. He gives you all of the code as well as a demo of the functionality for you to get a feel for what you're getting into...

tagged:

Link:


Trending Topics: