Please read CGI

"Is this is bytes or kb?"

From CGI: "If set to a non-negative integer, this variable puts a ceiling on the size of POSTings, in bytes."

"What do YOU think a fair size would be to restrict to?"

This is impossible to answer in a sane fashion, for you don't specify what is being uploaded. Are they JPEGs of pictures for a contest? Background images? In other words, please explain what you really want to be uploaded.

"What happens if the file they attempt to upload is greater than that of which I limited? Will the script die? I'd like to control this error if I could using something like if (size is to big) { print the size is to big; exit}, for a cleaner death error."

Again from CGI: "An attempt to send a POST larger than $POST_MAX bytes will cause param() to return an empty CGI parameter list. You can test for this event by checking cgi_error(), either after you create the CGI object or, if you are using the function-oriented interface, call <param()> for the first time. If the POST was intercepted, then cgi_error() will return the message "413 POST too large"."

"$CGI::POST_MAX. Can this be $CGI::$max_num and still work?"

What is $CGI::$max_num ?

"Is there an easy yet safe way to restrict file sizes on a specific variable/filehandle?"

Create several upload forms? I'm not sure how to handle this best, but I'm sure some other monks will help you out on this one.

--
b10m

All code is usually tested, but rarely trusted.

In reply to Re: Restricting file upload size by b10m
in thread Restricting file upload size by Anonymous Monk

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.