We help IT Professionals succeed at work.

AJAX - Upload Monitoring

Shroder
Shroder asked
on
Medium Priority
1,040 Views
Last Modified: 2011-08-18
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.
Comment
Watch Question

Commented:
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.

Author

Commented:
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.

Commented:
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.

Author

Commented:
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.
Commented:
If I understand this correctly, the patch ties into the PHP function that receives POSTS. In a loop there it updates a set of statistics in memory. When you call the upload_progress_meter_get_info function it gets these statistics from memory.

It's all done in C code in the PHP binary.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

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

That also explains why I couldn't find the function.

Commented:
Yep. More questions?

Author

Commented:
Sorry for the delay. That is all. Thank you for your help!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.