Forum Moderators: coopster

Message Too Old, No Replies

File Upload Progress Indicator

Is there a way to do this using only PHP

         

lobo235

3:25 pm on Sep 24, 2005 (gmt 0)

10+ Year Member



Is there a way that I can use PHP to show a file upload progress indicator? I have looked into this in the past and I determined there was no way to do it. I had an idea that came to me in a dream that I had recently. In my dream I was able to do it by looking at PHP's temp files and checking the modified date of the files to find the most recent one. I then used the filesize function to see how much had been uploaded so far. I know it's weird that I dream about PHP but I have had dreams before and when I tried to implement the stuff in my dreams it has worked before.

Any ideas on this?

ergophobe

4:33 pm on Sep 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not to be a bummer....

1. PHP can't do anything without resending a page (server side, remember). Since the response to the upload isn't sent until the upload is completed, PHP can only show a progress of 100%. In other words, even if you could use PHP to calculate the progress during the event, you have no way of showing it to the user that I can think of.

2. You can't assume that the most recent temp file relates to any one user. If 10 users are uploading at the same time, who has the "the most recent" temp file? How will you track that? I don't think there's any way to guard against concurrency.

I think the only way to do this is with a client-side application that knows the size of the original file and can track how many bytes have been sent.

lobo235

7:07 pm on Sep 24, 2005 (gmt 0)

10+ Year Member



Do you know of a cheap/free client side solution?

RonPK

7:45 pm on Sep 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's a script on SourceForge called megaupload that combines PHP and Perl to do the job. The Perl script reads the size of RAW_POST_DATA, which PHP cannot do.

I'm not sure whether I can post the URL; you'll have to search with Google for "php file upload progress". Sticky me if you can't find it.

lobo235

8:03 pm on Sep 24, 2005 (gmt 0)

10+ Year Member



Great! Thanks a bunch for the help.

jatar_k

9:26 pm on Sep 24, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



as a side note I seldom have any issues with SourceForge links. ;)