-
- # This is an (apparently undocumented) way to get the name
- # of the temp file that CGI writes the upload to.
- my $tempfile=$q->tmpFileName($filename);
+
+ my $tempfile;
+ if (defined $handle) {
+ # This is what works in CGI.pm 4.09+: $q->tmpFileName($q->upload('attachment'))
+ $tempfile=$q->tmpFileName($handle);
+ }
+ if (! defined $tempfile || ! length $tempfile) {
+ # This is what is *documented* in CGI.pm 4.09: $q->tmpFileName($q->param('attachment'))
+ $tempfile=$q->tmpFileName($filename);
+ }