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?