It sounds like you are attempting to use $file as a filename, instead of an open filehandle as described in the CGI.pm documentation.
my $file = $query->param('upload_file_name'); while (<$file>) { print "Got a line: $_"; }
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.

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.


In reply to Re: Uploading via HTML/Using CGI.pm by Fastolfe
in thread Uploading via HTML/Using CGI.pm by radagast

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.