Personally, I'd just set $CGI::POST_MAX, to reject big requests. In fact, you could probably set $CGI::POST_MAX to something a bit higher than the maximum file size (to allow for some additional data, like filename and other user input) and then check the file size after the upload succeeds.

From the docs:

$CGI::POST_MAX If set to a non-negative integer, this variable puts a ceil +ing on the size of POSTings, in bytes. If CGI.pm detects a POST t +hat is greater than the ceiling, it will immediately exit with an +error message. This value will affect both ordinary POSTs and mu +ltipart POSTs, meaning that it limits the maximum size of file uplo +ads as well. You should set this to a reasonably high value, such + as 1 megabyte.

Make sure you set it at the top of your script (before using any CGI.pm functions)

Joost


In reply to Re: STDIN and Browsers by Joost
in thread STDIN and Browsers by gorillaman

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.