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

I am using binmode due to the filetypes that could be uploaded. I also think its odd that the file exists, but sure as heck it does, at 0 bytes, in the correct directory on the web server

I do see your point about not testing the file, and it is valid. I probably cut some corners there, but only because I also am in control of the files that get uploaded.
The one I'm testing with is ~7kb in size.

  • Comment on Re^2: Having an issue with my CGI.pm file uploads

Replies are listed 'Best First'.
Re^3: Having an issue with my CGI.pm file uploads
by mr_mischief (Monsignor) on Sep 25, 2007 at 17:29 UTC
    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?

      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.