tags:

views:

35

answers:

1

I am attempting to modify the Uber-Uploader perl script so that when an upload is checked if it meets the minimum requirements, it checks per file instead of just the entire request.

I'm not too experienced with perl, and don't know how to do this. Currently the script simply does this:

elsif($ENV{'CONTENT_LENGTH'} > $config{'max_upload_size'}){
my $max_size = &format_bytes($config{'max_upload_size'}, 99);
die("Maximum upload size of $max_size exceeded");
}

All that does is check the content length of the request (which contains multiple files), and fail when the total is greater than the max allowed size.

Is there a way to check it per file?

Note: Changing upload scripts is not an option. Don't try

+1  A: 

I'm not sure what you mean by "Changing upload scripts is not an option.", but have you tried something like this?

my $q = CGI->new();
my @files = $q->upload();

foreach my $file (@files){
    if ((-s $file) > $config{'max_upload_size'}){
        die("Maximum upload size of $file exceeded");
    }
}

(NOTE: this is untested code!!!!!)

Matthew J Morrison
Will try, thanks
TheLQ