fraktalisman has asked for the wisdom of the Perl Monks concerning the following question:

I want to let users upload images to a site. My colleague installed a script using CGI_LIB.pl and it works fine, like a CGI.pm solution would, too. But one thing I didn't read anywhere was the possibility to set a limit on the amount of bytes that actually gets uploaded. Can anyone help?

Replies are listed 'Best First'.
Re: How to limit upload file size?
by chromatic (Archbishop) on Oct 09, 2000 at 19:52 UTC
    Set the $CGI::POST_MAX variable to the number of bytes of the desired limit. The documentation recommends that it be a megabyte or so, because it works on file uploads and ordinary POST requests.

    Update: Unfortunately, I seem to have misinterpreted your post as saying that you'd moved *away* from cgi_lib.pl *to* CGI.pm. Since I was backwards, I can only recommend you look into the ReadParse() method in CGI for compatibility purposes.

    cgi_lib.pl is pretty limited and hasn't been updated in years.

Re: How to limit upload file size?
by AgentM (Curate) on Oct 09, 2000 at 20:43 UTC
    If you can, use CGI.pm instead. cgi_lib.pl isn't too friendly when it comes to limiting that value (you'd have to hack it yourself). CGI.pm also gives you many more benefits and functions that you can use, not to mention being more overly secure than any predecessor. I'm sure merlyn or tilly would be happy to argue about it more with you. (I'm sure hairs are growing out of their foreheads because of this debate.)
    AgentM Systems or Nasca Enterprises is not responsible for the comments made by AgentM- anywhere.