strange behavior when using 'read'

From: sstark (sstark_at_us.ibm.com)
Date: 03/06/05

  • Next message: Joe Smith: "Re: LibXML UTF8 - Input is not proper UTF-8, indicate encoding !"
    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


  • Next message: Joe Smith: "Re: LibXML UTF8 - Input is not proper UTF-8, indicate encoding !"

    Relevant Pages

    • Re: automated upload with PHP
      ... have your script one once per day and upload any images not already ... tiffs and the php script, ... // request local file read permission ...
      (comp.lang.php)
    • [UNIX] Cobalt Raq XTR Combination Attack (Remote/Local)
      ... Due to an authentication bug in the upload Handler, ... The next problem lies in the base64 encoding of the filename, ... After the symlinks have been created (script to create base64 symlink is ...
      (Securiteam)
    • Re: automated upload with PHP
      ... have your script one once per day and upload any images not already ... providing it can have an ftp serve running on it, ... tiffs and the php script, ...
      (comp.lang.php)
    • Re: automated upload with PHP
      ... have your script one once per day and upload any images not already ... providing it can have an ftp serve running on it, ... tiffs and the php script, ...
      (comp.lang.php)
    • Re: IIS Security Question
      ... input that changes the operation of the ASP code in some ... >that folder would only be accessible via the upload ... >script can't be misused, ... >another folder, or uploading an ASP script to a folder ...
      (microsoft.public.inetserver.iis.security)