Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
ok there is five upload fields, and when checking for errors I say: if (($left - (length($file))) < 0) { &inerror("You are out of space in your $format_limit limit, you only have $format_left left."); } Since this is like a file manager, say they have a space limit of 10mb but there was only 1mb left($left), and we find the length of the file and minus by what is left, and if its less than zero then there over it. Well what my trouble is, they well upload a script and it will be over the limit it wont say anything, but if they upload again while it is over the limit then it will show the erorr. It shouldn't be doing this. Any Ideassub uploadfile { &bytes; for ($i=1; $i<=5; $i++) { if ($q->param("file$i")) { $file = $q->param("file$i"); $format_left = format_size($left); if (($left - (length($file))) < 0) { &inerror("You are + out of space in your $format_limit limit, you only have $format_left + left."); } foreach $line (@badtypes) { if ($q->param("file$i") =~ /$line/) { &inerror("Invaild fil +e type"); } } $filename = $q->param("file$i"); $filename =~ s/.*[\/\\]//; open (OUTFILE,">$user{'site_id'}/$filename") || &error("Could +not create $filename: $!"); lock(OUTFILE); binmode OUTFILE; while ($bytesread=read($file,$buffer,2024)) { print OUTFILE $buffer; } close (OUTFILE); } } }
2002-06-15 Edit by Corion : Changed title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Problem
by Anonymous Monk on Jun 15, 2002 at 04:50 UTC |