The more I think about this challenge, the less I think the http solution will work and still be reliable (http certainly was not designed for it).
As for upload_hook, I found it in the CGI.pm page on CPAN.org:
You can set up a callback that will be called whenever a file upload is being read during the form processing. This is much like the UPLOAD_HOOK facility available in Apache::Request, with the exception that the first argument to the callback is an Apache::Upload object, here it's the remote filename.
$q = CGI->new();
$q->upload_hook(\&hook,$data);
sub hook
{
my ($filename, $buffer, $bytes_read, $data) = @_;
print "Read $bytes_read bytes of $filename\n";
}
If using the function-oriented interface, call the CGI::upload_hook() method before calling param() or any other CGI functions:
CGI::upload_hook(\&hook,$data);
This method is not exported by default. You will have to import it explicitly if you wish to use it without the CGI:: prefix.