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

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
mlh2003

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?

    untested:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://507060]
help
Chatterbox?
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
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (70 votes). Check out past polls.

    Notices?