I had to solve this exact problem about 6 months ago for an application that parsed uploaded files real time and fed back progress indicators to the user. There is a great description of how to do a search in progress out there by merlyn, but this situation is a bit different in that the main application window is handling the upload, and cannot be refreshed.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.