in reply to Re: To know parameter size in CGI.pm
in thread To know parameter size in CGI.pm

... the limits can be easily avoided
Please correct me if I misunderstood your answer. The reason I want to know the size is to abort the web submission process when the input/upload is too large.

So my worry is not that the input is too small, on the contrary I want to avoid data input of certain size, be it file_upload or text_field input.

Regards,
Edward

Replies are listed 'Best First'.
Re^3: To know parameter size in CGI.pm
by derby (Abbot) on May 20, 2006 at 14:46 UTC

    The reason I want to know the size is to abort the web submission process when the input/upload is too large

    Right ... the client does not send that data back to you on a per-field basis. You can abort if all the data is too large but per field, you need to actually read the param before you can determine if it's too big for your needs.

    To limit for all POST data, follow the example from CGI:

    use CGI qw/:standard/; use CGI::Carp ’fatalsToBrowser’; $CGI::POST_MAX=1024 * 100; # max 100K posts
    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".

    -derby