Monks,

I'm currently using CGI::Application to provide some dynamic web content for a community website that I support.

As part of this, we want to allow users to upload an image for their personal profiles, with a maximum size of 80kb. This has been implemented, using the $CGI::POST_MAX variable to limit the size of uploads.

This seems to work well: if a file over the limit is uploaded, it's ignored, and the script returns (automatically, not through my scripting) to the site's homepage. What I'd like to do, however, is to catch the error, and display an error message, so that the user at least knows what went wrong.

I've looked through the docs for CGI, super-searched here and searched the web for some hints about how to do this, but I'm having no luck so far.

Does anyone know of a way to detect the fact that a file upload has exceeded the $CGI::POST_MAX limit, and hence failed, so that an error can be displayed? As the file doesn't actually get uploaded, I presume that the upload error-detection code given in the CGI module wouldn't work in this case.

Any suggestions would be appreciated.

-- Foxcub
#include www.liquidfusion.org.uk


In reply to Detecting when a $CGI::POST_MAX limit is exceeded by Tanalis

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.