I did this in a mod_perl2 handler using Apache::Request, but you should be able to accomplish the same with cgi scripts. Upon the user clicking 'Upload', I used javascript to open a small status window which refreshed waiting for the presense of upload status data. Meanwhile the main window begins the upload process. An UPLOAD_HOOK (see a::r docs) subroutine measured the amount of bytes received from the client and wrote it to a status file which the monitor read.
Now, this worked very well for displaying the amount of bytes received from the user. As for determining the percentage of file uploaded, a::r provides the following useful method:
my $size = $upload->size;
However I did not find the size returned to be reliable when referenced from within the UPLOAD_HOOK subroutine. I suspect is determined once the file is fully uploaded. So I wasn't able to give the user a realistic estimation of when the file would be done uploading.
But I was able to parse the contents real-time, display the results to the user, and terminate the upload if the errors in the file exceeded a certain threshold, which got good feedback from the users. I got some flak from reviewers of the technique, but it worked very well. I was able to pass back to the user accurate information about where in the file errors were, which saved them a great deal of time.
HTH
In reply to Re: Upload Progress Bar
by redhotpenguin
in thread Upload Progress Bar
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |