in reply to Detecting when a $CGI::POST_MAX limit is exceeded
I have an upload script that relies *solely* on the CGI.pm module, and the script incorporates a "maximum size" testing feature that has worked for me. Here's the snippet I use as the uploaded file is being "read in" during the upload:
Given the level of knowledge at perlmonks, I may likely find out there's something wrong with the way I've got things set up ;), but as a said, the code above has worked for me for quite awhile.$max_size = '100000'; #set your max size value $totalbytes=0; open (IMAGESAVE,">$image_upload_directory/$final_name"); while ($bytesread=read ($file,$data,1024)) { $totalbytes+=$bytesread; if ($totalbytes > $max_size) { unlink ("$image_upload_directory/$file_name"); &FileTooLarge; #call your error sub exit; } print IMAGESAVE $data; } close IMAGESAVE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Detecting when a $CGI::POST_MAX limit is exceeded
by Hagbone (Monk) on May 26, 2003 at 21:58 UTC |