CGI-ProgressBar
view release on metacpan or search on metacpan
don't fancy.
CGI UPLOAD HOOK
I'm not convinced it works yet, even in CGI.pm verion 3.15.
If anyone knows otherwise, please mail me: I have spent an hour on
the below, and it seems that the hook is called more times than
necessary....
PROCESS
The script has to both upload and process a file.
The hook script is called when the object is constructed, thus
before any headers can be output. There the hook needs to output its
own headers, and we only output headers for the 'select file' page
when the hook has not been called.
The first tiem the hook is called, then, it outputs HTTP headers and
begins the page. This is fine.
The next time it is called, it outputs the JS call to update the
my $hook_called;
my $cgi = CGI->new(\&bar_hook, $data);
if (not $hook_called){
print $cgi->header,
$cgi->start_html( -title=>'A Simple Example', ),
$cgi->h1('Simple Upload-hook Example');
}
print $cgi->start_form( -enctype=>'application/x-www-form-urlencoded'),
$cgi->filefield( 'uploaded_file'),
$cgi->submit,
$cgi->end_form,p;
if ($cgi->param('uploaded_file')){
print 'uploaded_file: '.param('uploaded_file');
}
sub bar_hook {
my ($filename, $buffer, $bytes, $data) = @_;
if (not $hook_called){
print header,
start_html( -title=>'Simple Upload-hook Example', ),
h1('Uploading'),
p(
"Have to read <var>$ENV{CONTENT_LENGTH}</var> in blocks of <var>$bytes</var>, total blocks should be ",
lib/CGI/ProgressBar.pm view on Meta::CPAN
=head1 CGI UPLOAD HOOK
I'm not convinced it works yet, even in F<CGI.pm> verion 3.15.
If anyone knows otherwise, please mail me: I have spent an hour
on the below, and it seems that the hook is called more times
than necessary....
=head2 PROCESS
The script has to both upload and process a file.
The hook script is called when the object is constructed,
thus before any headers can be output. There the hook needs
to output its own headers, and we only output headers for
the 'select file' page when the hook has not been called.
The first tiem the hook is called, then, it outputs HTTP
headers and begins the page. This is fine.
The next time it is called, it outputs the JS call to
lib/CGI/ProgressBar.pm view on Meta::CPAN
my $hook_called;
my $cgi = CGI->new(\&bar_hook, $data);
if (not $hook_called){
print $cgi->header,
$cgi->start_html( -title=>'A Simple Example', ),
$cgi->h1('Simple Upload-hook Example');
}
print $cgi->start_form( -enctype=>'application/x-www-form-urlencoded'),
$cgi->filefield( 'uploaded_file'),
$cgi->submit,
$cgi->end_form,p;
if ($cgi->param('uploaded_file')){
print 'uploaded_file: '.param('uploaded_file');
}
sub bar_hook {
my ($filename, $buffer, $bytes, $data) = @_;
if (not $hook_called){
print header,
start_html( -title=>'Simple Upload-hook Example', ),
h1('Uploading'),
p(
( run in 2.921 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )