Hello, working with this right now myself.

The first three parameters to the upload_hook() routine are supplied by CGI.pm. The last fourth parameter is optionally provided by you in the new() call, and is passed to the hook routine as a convenience for you.

In my recent code I am doing
my $q = CGI->new( \ &WhizBang::upload_hook, $self ); # where $self is a ref to the current WhizBang object # then later sub upload_hook { my $remote_filename = shift; my $buffer = shift; my $bytes_read = shift; my $self = shift; my $progress = $self->param('progress'); my( $filename ) = $remote_filename =~ m/^ (?: .* [:>\]\\\/] )? ( .* +) $ /xs; $progress->{file_name} = $filename; $progress->{bytes_xfrd} = $bytes_read; $progress->{time_now} = time(); # other processing to output data to external storage # for display from another script }
Elsewhere I grab the value in $ENV{CONTENT_LENGTH} to compare against the $bytes_read value.

I have a couple of quibbles about this recent addition to CGI.pm, but at least the optional last $data parameter makes finding and updating your 'home' data structure possible.

As far as what you can do with this, yes, you pretty much must capture the data and write it to some place that _another_ script can find it for display. Once CGI.pm starts processing the POST'ed data (when you call new()) it will not return until all nnnMB and nn files are done being received. I'm writing the progress information to a database for a Javascript spawned window to find.

Some of these recent posts have references to examples:
Upload Progress Bar
Deferred/selective processing in CGI.pm
Upload Progress
Re: Re: CGI.pm and Large File Transfers


In reply to Re: Upload hook syntax and location by shenme
in thread Upload hook syntax and location by Andre_br

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.