Link to home
Start Free TrialLog in
Avatar of Shroder
Shroder

asked on

AJAX - Upload Monitoring

I found a script that actually monitors an upload, and I was trying to figure out how it works. Unfortunetly I can't find the function that collects the statistics in the source (I can just see it being called). So I'm hoping someone here can shed some light on how to do an upload progress bar with ajax.
Avatar of pvginkel
pvginkel
Flag of Netherlands image

If this is the system I think you're talking about; if I remember correctly I dropped that because it required recompilation of PHP or Apache (don't remember which). It's quite complicated to use this.

Just maybe though you'd like to know.

On the other hand; if you'd like an answer on your question, please post a reference or code.
Avatar of Shroder
Shroder

ASKER

http://bluga.net/projects/uploadProgressMeter/

That is where I saw the example, and got the code from.

I thought it would probably be complicated, so for right now I'm just wanting to get an understanding of how it is done. I was hoping of figuring that out by looking at the function I mentioned before.
I believe that how this works is that the pach adds the function upload_progress_meter_get_info. This function depends on the hidden variable UPLOAD_IDENTIFIER that was set to a random value when the upload form submits. That random value can then be used to retrieve data about the upload.

What you have to understand is that this works parallel. In other words: while the form is uploading, you call a secondary PHP page every second and call the function upload_progress_meter_get_info to ask how far the upload is. In reality, you open two HTTP connections, one of which is uploading the files while the other is used to get statistics.
Avatar of Shroder

ASKER

The part that has me stumped is how the second php page/script can keep track of the upload progress. Is it taking the size of the tmp file on the server? If so is the first php script (that the file is being uploaded to) set to upload the file to some place other then tmp?

Thanks for your help so far.
ASKER CERTIFIED SOLUTION
Avatar of pvginkel
pvginkel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shroder

ASKER

ahh. So that is where you have to recompile the php binary?

That also explains why I couldn't find the function.
Yep. More questions?
Avatar of Shroder

ASKER

Sorry for the delay. That is all. Thank you for your help!