in reply to uploadInfo - can't use undefined value as a HASH reference

The best way to find out what's going on, and a good programming practice in general, is to add better error checking:
use strict; use CGI; my $q = CGI->new() or die "Couldn't create CGI object!\n"; sub mimetype { my $file = shift; my $info = $q->uploadInfo($file) or die "No file '$file' was uploaded!\n"; my $mimetype = $info->{'Content-Type'} # line 804 or die "Uploaded file had no Content-type!\n"; return $mimetype; }

Replies are listed 'Best First'.
Re: Re: uploadInfo - can't use undefined value as a HASH reference
by kiat (Vicar) on Apr 20, 2004 at 02:46 UTC
    Thanks, sgifford :)

    I did that. It says 'No file '$file' was uploaded'. But the file does get saved into the appropriate directory. Could it be because I'm calling mimetype() (which is in Subs.pm) from another module (Upload.pm) that doesn't have 'use CGI' i.e. 'use CGI' is only imported in Subs.pm?