in reply to Upload hook syntax and location
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.
Elsewhere I grab the value in $ENV{CONTENT_LENGTH} to compare against the $bytes_read value.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 }
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Upload hook syntax and location
by Anonymous Monk on Dec 29, 2004 at 03:30 UTC | |
by shenme (Priest) on Dec 29, 2004 at 05:03 UTC | |
by Andre_br (Pilgrim) on Dec 29, 2004 at 03:33 UTC |