Thanks fliptop. The $CGI::POST_MAX variable worked well.
What if I now want to upload 2 files. The first can be up to 100k in size and the second up to 80k in size? That is pretty much the way I have it set up at the moment... Or should I admit defeat at this stage and allow 2 files to be uploaded that have a combined size of 180k maximum? Is there a way of knowing the file size after say: my @pic_filenames = ($query->param('picfile1'), $query->param('picfile2')); where picfile1 & picfile2 are defined from the multipart/form-data post. Can I then check the size along the lines of (where FILESIZE is some function to get the size of a file)... if (( FILESIZE (@pic_filenames[0]) > 1024*100) || (FILESIZE (@pic_filenames[1]) > 1024*80)) { # print error message here } Thanks in advance, Mike. > On Fri, 18 Jul 2003 at 12:03, Mike Harrison opined: > > MH:I have a perl program that allows a user to upload a file (either .jpg or > MH:.gif) to the server, and returns a message if it exceeds a specified size > MH:(in my case 100kB). Currently (and don't laugh - I am new to perl), I go > MH:through the motions of uploading the file in 1024-byte blocks (in binary > MH:mode), and increment a counter with each block. If the counter exceeds 100 > MH:(i.e. greater than 100kB), then it exits the loop, displays a warning > MH:message and deletes the file. > MH: > MH:I am sure there would have to be an easier and more efficient way of doing > MH:this - that is, somehow finding out how large the file is without having to > MH:download it first. > MH: > MH:Does perl have a module that can check the size of the file? And for that > MH:matter, its type (.jpg, .gif etc.)? > > hi mike - CGI provides a way to indicate if an form post exceeds a > pre-determined size limit. it's the $CGI::POST_MAX variable, and if you > wanted to limit uploads to 100kbytes (for example), you'd do something > like this: > > use CGI; > $CGI::POST_MAX = 100 * 1024; > > my $cgi = new CGI; > > if ($cgi->cgi_error) { > # alert the user their post exceeded the limit > exit(); > } > > you can find out more information by reading > > perldoc CGI > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]