in reply to Uploading via HTML/Using CGI.pm
Treating $file as a string will give you the filename that the user selected, as if it were a simple text input box. Thus, attempting to open this will fail unless you're on the same system. That's not how it was intended to work anyway. In any browser (except IE on a Mac so far as I've been able to tell), you can just type text in file input fields, without necessarily needing a valid file. This would allow arbitrary strings to appear in $file, which is a huge security problem if you're attempting to blindly open that filename. Treat it as a filehandle.my $file = $query->param('upload_file_name'); while (<$file>) { print "Got a line: $_"; }
You may wish to examine the 'FILE UPLOAD' section of the CGI.pm documentation. It goes into considerable detail about all of this, as well as the tmpFileName method another poster mentioned. It even has examples.
|
|---|