I certainly agree that you should do taint-checking on the name of the file the users sends you... A simple open UPLOADFILE, ">$upload_dir/$file" could corrupt data depending on the application, and the configuration of the webserver. (even worse would be chdir $upload_dir;open UPLOADFILE, ">$file";

In my opinion you should ALWAYS use the three arguments version of open (something like: open UF, ">", "$upload_dir/$filename" or die $!). , since this does not allow a mode change... (and a mode change could corrupt one of your files and/or your script's configuration file (wihtout knowing the file's name that is, but that depends on the script), and/or running files (but only when there is no mode, in case this this is impossible since you have ">"))

As a side note: the OP's code does not need 64kb of data to work, 'read' will try to read a maximum of 64kb of data. (which is quite different)


In reply to Re^2: File uploading methods compared by Animator
in thread File uploading methods compared by bradcathey

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.