$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"); } ...