You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brian Dimeler <br...@lserve.com> on 2006/03/28 22:24:08 UTC

[mp1] CGI upload_hook with PerlRun

Hi,

  I have a file-uploading script from a server running perl scripts as plain old CGI, and I'm trying 
to port it to an Apache 1.3 server using PerlRun. Everything works except CGI's upload hook. On the 
vanilla CGI server, the upload hook routine is called repeatedly during the upload process, but 
under mod_perl, nothing happens until the file is finished uploading, at which point the upload hook 
appears to be called a zillion times in the space of a second or two (based on the logs).

Could anyone shed some light on why this behavior is different under mod_perl, and if there's a way 
around it? CGI.pm's docs mention an "Apache UPLOAD_HOOK" feature, but I don't know how I would go 
about incorporating that in a PerlRun script as it uses Apache::Request objects..

For reference, I'm running:
  Mac OS X Server 10.4.5 with original built-in versions of perl (5.8.6), Apache (1.3.29), mod_perl 
and CGI.pm (3.05)

Snip from the script in question:

use CGI;
my $uploaddir = '/path/to/uploads/';
my $data = {};
my $query = new CGI sub {
	my ($file, $b, $bytes, $d) = @_;
	open my $fh, ">$uploaddir$file.uploadCount";
	$$d{$file} = $bytes;
	print $fh $bytes;
	close $fh
	print STDERR localtime() . ": upload hook called - $file, $bytes\n"
}, $data;
unlink "$uploaddir$_.uploadCount" for keys %$data;
# all file copying, form processing and output goes below here