You have already been told how to get the result you want, but not why it was done this way.

The thought was that the browser sends the actual filename of what is sent, and that information can be useful, so it should not be lost. However that name can have any garbage, and so should not be trusted. Furthermore the name of the temporary file that has the data should be irrelevant to you, you just want to get the data and do something with it.

Therefore the API was chosen so that you can get all of the information that is relevant to you and the temporary file is managed without any work on your part. (I also think that it tends to confuse people to have this magical thing which can be used as a string or a filehandle both, but that is how it was done.)


In reply to Re (tilly) 1: CGI.pm's upload gives local filename, not file itself by tilly
in thread CGI.pm's upload gives local filename, not file itself by Wallamaster

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.