$filename is not a filehandle. The "param()" method returns the file name but not an opened filehandle to it. This file name cannot be opened directly with an "open()" as the file does not exist on your filesystem, it is the file name on the client host.

If your CGI.pm does not handle the "upload()" method you can upgrade it (with perl -MCPAN -e 'install CGI') or, if you don't have root access to the webserver, grab an updated CGI.pm module file and put it in a directory on your webserver and load it in your scripts with:
use lib "/where/is/your/cgi/module"; use CGI;
That should load this newest module instead of the system default module.

update: cfreak is right and i'm absolutely wrong. I checked the doc, and param() on an upload field returns a filename that is also a filehandle. Thanks cfreak.

In reply to Re: Upload a file from a web form by choocroot
in thread Upload a file from a web form by bodmin

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.