in reply to Re: Re: I've got a problem with the file upload code
in thread I've got a problem with the file upload code

You want to put the binmode after the open of the file. You also probably want to add a binmode for $file_handle.

An undef $file_handle means that the upload failed, for some reason. If you use CGI::Carp you can see the warnings and/or fatal errors from your script.

  • Comment on Re: Re: Re: I've got a problem with the file upload code

Replies are listed 'Best First'.
Re: Re: Re: Re: I've got a problem with the file upload code
by Agermain (Scribe) on Jun 28, 2001 at 21:56 UTC

    Thanks again for your help, bikeNomad. I think I finally figured out what was malfunctioning in Ovid's original code.

    • I used my $file_handle = $req->upload("FILE$onnum"); instead of my $file_handle = $req->upload($file);
    • I used open(OUTFILE, ">" . UPLOAD_DIR . $fileName) instead of the sysopen command. Not sure WHY it worked, but it worked.

    I think the thing that confused me most was that $file_handle was acting like both a standard scalar string and a filehandle, since I could print $file_handle and get a readable filename/directory - most of the times if I see a reference, it looks like... a reference.

    CGI::Carp definitely helped out... It's much more useful to get error feedback instead of a vague "this didn't work" error! Thanks again for your help!!