strange behavior when using 'read'
From: sstark (sstark_at_us.ibm.com)
Date: 03/06/05
- Previous message: Jeff Seale: "displaying STDOUT containing multiple data entries"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Mar 2005 18:27:49 -0800
Hi, I have a web/cgi script that allows users to upload a file to the
web server. I want to only allow files up to a certain size, which is
stored in $imageFileMaxSize (typically 75K). That part works correctly,
i.e. the script does not allow uploads larger than $imageFileMaxSize.
The problem is, when a user attempts to upload a file larger than
$imageFileMaxSize, the on_error routine is not called; instead the
script reloads from its starting point, with no message. My users find
this confusing, sometimes thinking the file has been uploaded,
sometimes getting frustrated and trying again.
How can I get on_error to display the proper message? Here's my code:
$imageFileMaxSize = 75000;
$CGI::POST_MAX = $imageFileMaxSize;
sub create_new_image_file {
my $newImageFile = @_;
$file = param('imagefile');
open (SAVE, ">$newImageFilenamePath")");
while (read($file,$data,1024)) {
print SAVE $data;
$imageFileLength += length($data);
on_error("Image file is too large; maximum size allowed is
$imageFileMaxSize") if($imageFileLength > $imageFileMaxSize);
}
close(SAVE);
on_error("File was not received; check filename.") if($imageFileLength
< 1);
}
thanks!
Scott
- Previous message: Jeff Seale: "displaying STDOUT containing multiple data entries"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|