in reply to CGI file upload solution
Great post and good starting point.
The CGI perl module already has a mechanism for allowing you to monitor the progress of an uploading file, using the upload_hook.
In fact, by the time you call upload() to get a file handle, CGI has already uploaded the entire file to a temporary file on your server. You may have noticed a big delay from when you submit a large file and when you start to see progress on that upload. What you are doing, is actually just copying the data from a temp file, that CGI already created, to your own specified file.
See CGI.pm and the documentation for more info on upload_hook. You have define the upload_hook as soon as you create the CGI object or it won't work. Here is one way to do it:
my $query = CGI->new(\&hook); sub hook { my ($filename, $buffer, $bytes_read,$data) = @_; $cache->set($progress_key, [0, $bytes_read]); }
-Scott
|
|---|