Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Setting CGI::POST_MAX with CGI::Application

by mlh2003 (Scribe)
on Nov 09, 2005 at 13:03 UTC ( #507060=note: print w/replies, xml ) Need Help??

in reply to Setting CGI::POST_MAX with CGI::Application

You can explictly set $CGI::POST_MAX to some value in your instance script. You will need to pass the query object via the new() method so that it is inherited by your application module.
For example, your instance script may look like:
#!/usr/bin/perl -T use strict; use warnings; use lib '/home/lib'; use Current::My_App; use CGI; $CGI::POST_MAX=102400; # Limit post to 100kB $CGI::DISABLE_UPLOADS=0; # Allow file uploads my $q=CGI->new; # Create query object if ($q->cgi_error()) { print $q->header(-status=>$q->cgi_error()); exit 0; } my $app=Current::My_App->new(query=>$q); $My_App->run();

As for determining the MIME type of a file, the File::Type module might be useful for your needs.
Code is untested unless explicitly stated

Replies are listed 'Best First'.
Re^2: Setting CGI::POST_MAX with CGI::Application
by derby (Abbot) on Nov 09, 2005 at 13:08 UTC

    Wouldn't overriding CGI::Application's cgiapp_get_query method be cleaner?


    sub cgiapp_get_query { my $self = shift; # Include and related modules require CGI; $CGI::POST_MAX=102400; $CGI::DISABLE_UPLOADS=0; # Get the query object my $q = CGI->new(); return $q; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://507060]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2021-10-17 01:32 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (70 votes). Check out past polls.