in reply to Re^2: Having an issue with my CGI.pm file uploads
in thread Having an issue with my CGI.pm file uploads

You're not using binmode() on $upload_filehandle, though. You want to make sure you read in binary mode, too.

As for file size, if you have binary data in the input file but it's not in binary mode, you could have issues there.

Also, make sure you have a version of CGI.pm that doesn't have the fairly recent broken upload problem. CGI 3.21 and 3.22 simply don't work for uploads. See Skip CGI.pm versions 3.21 and 3.22 when upgrading -- they break the upload() method for more info. It could be you're not getting a file uploaded because the library really is broken.

What does print $CGI::VERSION; give you?

Replies are listed 'Best First'.
Re^4: Having an issue with my CGI.pm file uploads
by technojosh (Priest) on Sep 25, 2007 at 20:57 UTC
    my CGI.pm version is 3.10

    If I try:

    my $upload_filehandle = $i->upload( 'JARFILE' ); binmode($upload_filehandle);
    I get the following error in my apache log:
    Can't use an undefined value as a symbol reference
    ...so now I am confused, why my filehandle is not getting defined. It is on a valid file upload field, as again, the file(complete with its remote name) is getting created at 0 bytes on the server.
      The CGI.pm docs say that the upload() method will return undef if the argument is not a valid file handle. It doesn't go into much detail about what would cause that to be the case.

      One thing CGI.pm will try to do is to save the uploaded file in your temporary directory. On *nix, that's usually /tmp, but it may differ under certain setups. On Windows, depending on server software and such, c:/temp, d:/temp, c:/windows/temp, 'c:/documents and settings/user/local settings/temp' and others are all possibilities. CGI.pm may have issues if it can't do that due to permissions, so that's a good place to check.