G
George Magklaras
In an attempt to control the file upload size on a PERL 5.6.1 CGI
script, I used my own counters to set the maximum size of the file to
around 4 MBytes. So I had my traditional while loop that looks like
this (inside a subroutine):
sub UploadFile {
..
..
..
my $buffersize = 65_536;
my $maxBuffers = 64;
..
..
..
while(read( $fh, $buffer, $buffersize)) {
$cnter++;
if ($cnter <= $maxBuffers) {
print UPLOAD $buffer;
} else {
$returnData = 'uploaded file too big';
return $returnData;
}
..
..
..
}
The subroutine works. it starts uploading the file and then when the
file goes over 4MBytes, it drops out...Which is fine, but some people
may have extremely low-speed connections, so it may take some time to
discover that after waiting 10-20 minutes to upload the 4 Megs, they
cannot continue. Hence, what I really want is to know the size of the
file to-be-uploaded before hand.
I am wearing CGI::Corp and CGI::Safe and I read that CGI:OST_MAX can
also be used to limit the size of the HTTP POST operation. The
questions I have are:
1)Does this happen at the very beginning of the POST operation, or
right after the file has already occupied 4Mbytes of RAM/Disk space.
What I want is to prevent the operation from the very beginning if the
file exceeds 4Megs.
2)If the answer to the previous question is 'No, it happens at the
end.', does someone now of a reliable (aka browser independent way) to
'probe' the size of the file-to-be-uploaded from the very beginning?
Regards,
George Magklaras
script, I used my own counters to set the maximum size of the file to
around 4 MBytes. So I had my traditional while loop that looks like
this (inside a subroutine):
sub UploadFile {
..
..
..
my $buffersize = 65_536;
my $maxBuffers = 64;
..
..
..
while(read( $fh, $buffer, $buffersize)) {
$cnter++;
if ($cnter <= $maxBuffers) {
print UPLOAD $buffer;
} else {
$returnData = 'uploaded file too big';
return $returnData;
}
..
..
..
}
The subroutine works. it starts uploading the file and then when the
file goes over 4MBytes, it drops out...Which is fine, but some people
may have extremely low-speed connections, so it may take some time to
discover that after waiting 10-20 minutes to upload the 4 Megs, they
cannot continue. Hence, what I really want is to know the size of the
file to-be-uploaded before hand.
I am wearing CGI::Corp and CGI::Safe and I read that CGI:OST_MAX can
also be used to limit the size of the HTTP POST operation. The
questions I have are:
1)Does this happen at the very beginning of the POST operation, or
right after the file has already occupied 4Mbytes of RAM/Disk space.
What I want is to prevent the operation from the very beginning if the
file exceeds 4Megs.
2)If the answer to the previous question is 'No, it happens at the
end.', does someone now of a reliable (aka browser independent way) to
'probe' the size of the file-to-be-uploaded from the very beginning?
Regards,
George Magklaras