Llew_Llaw_Gyffes has asked for the wisdom of the Perl Monks concerning the following question:
I have a web gallery application which, not unreasonably, allows photo uploading. The code that handles uploads, stripped of redundant parts, is essentially this:
$q = CGI->new(); %form = $q->Vars; ... $file = $form{photo}; $fh = upload('photo') || error ($q,"Cannot upload file $file"); $info = uploadInfo($q->param('photo')) || error ($q,"Could not get + information about $file!"); unless ($errors) { $type = $info->{'Content-Type'}; unless ($type =~ m,^image/(jpeg|gif|png)$,) { error ($q, "File type '$type' is not permitted"); } ...
When I test this code from the submission form, all the form fields appear correct, upload() succeeds, but uploadInfo() fails. In the absence of the check for errors, this causes $info->{'Content-Type'} to throw an 'undefined value as HASH reference' error. $q->cgi_error sheds no light on the failure.
Can anyone suggest why uploadInfo() is failing, even though upload() has succeeded?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI.pm: upload() succeeds, uploadInfo() fails
by geektron (Curate) on Jul 21, 2005 at 20:15 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Jul 21, 2005 at 20:40 UTC | |
|
Re: CGI.pm: upload() succeeds, uploadInfo() fails
by kutsu (Priest) on Jul 21, 2005 at 20:22 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Jul 21, 2005 at 20:44 UTC | |
by Anonymous Monk on Jul 22, 2005 at 05:08 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Jul 23, 2005 at 04:42 UTC |