$CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX=1024 * 100; # max 100K posts
if ($Q->cgi_error()) {
$message = $Q->cgi_error()."<p>CGI Error";
&error_trap($message);
}
Could someone please tell me how to implement this when using CA?
Setting the global variables can still be done in C::A.
As for returning an error to the user, what did you try to do in C::A
that didn't work?
Mark
First I tried this at the top of my app:
use base 'CGI::Application';
use CGI::Application::Plugin::AutoRunmode;
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::Authentication;
use CGI::Application::Plugin::Forward;
$CGI::POST_MAX=1024 * 100; # max 100K posts
and this at the beginning of my upload sub routine:
sub prefs_upload_logo : RunMode {
my $self = shift;
my $Q = $self->query();
if ($Q->cgi_error()) {
$message = $Q->cgi_error()."<p>CGI Error";
&error_trap($message);
}
Then I tried this:
sub cgiapp_init {
my $self = shift;
CGI::POST_MAX=1024 * 100; # max 100K posts
# and this:
$CGI::POST_MAX=1024 * 100; # max 100K posts
# Set the CGI::Session cookie name
CGI::Session->name('Fox');
# Configure the session
$self->session_config(CGI_SESSION_OPTIONS => [ "driver:File",
$self->query, {Directory=>$SetUp::session_path} ],
DEFAULT_EXPIRY =>
"$SetUp::session_length" ,
COOKIE_PARAMS => {-path
=> '/',},
SEND_COOKIE => 1);
}
sub prefs_upload_logo : RunMode {
my $self = shift;
my $Q = $self->query();
if ($Q->cgi_error()) {
$message = $Q->cgi_error()."<p>CGI Error";
&error_trap($message);
}
# and this
sub prefs_upload_logo : RunMode {
my $self = shift;
if ($self->cgi_error()) {
$message = $self->query->cgi_error()."<p>CGI Error";
&error_trap($message);
}
# and even this.
sub prefs_upload_logo : RunMode {
my $self = shift;
if ($self->query->cgi_error()) {
$message = $self->query->cgi_error()."<p>CGI Error";
&error_trap($message);
}
and several other various combos of shots in the dark. After a bit I
went back to cpan and looked for an example but haven't found one yet.
It seems to me that putting "$CGI::POST_MAX=1024 * 100;" underneath my
declared modules should stop uploads larger than 100k, even if I don't
trap the error, but it does not.
Finally, I set up this test script and started uploading 100k files to
it:
<code>
#!/usr/bin/perl
use CGI;
$CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX=1024 * 10;
my $Q = new CGI;
# Trap post that are too large here...
if ($Q->cgi_error()) {
$message = $Q->cgi_error()."<p>CGI Error";
print $Q->header;
print $Q->start_html(-title => "Error");
print "$message";
print $Q->end_html;
exit
}
else {
print $Q->header;
print $Q->start_html(-title => "Hi Bill");
print "Hi Bill";
print $Q->end_html;
exit
}
</code>
when using only "$CGI::DISABLE_UPLOADS = 1;" it does not print the
error page, and it does not respond until after the file has finished
uploading.
using only "$CGI::POST_MAX=1024 * 10;" will print the error page, but
it seems only after the file has been uploaded.
So, that's where I stand. (knee deep)
Kindest Regards,
--
Bill Stephenson
417-546-8390
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]