sub 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); } } }
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 Ideas

2002-06-15 Edit by Corion : Changed title


In reply to Size limiting a CGI upload (was: Perl Problem) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.