in reply to Problems Uploadng a file

You might want to check on $fh before doing something with it
my $fh = $query->upload('upload_file'); if ( defined $fh ) { # do your stuff }

Replies are listed 'Best First'.
Re^2: Problems Uploadng a file
by lmck2 (Initiate) on Sep 13, 2011 at 22:44 UTC
    The $fh doesn't seem to be where the problem is. I put a
    while ( $bytesread = read $fh, $buffer, 1024 ) { print "$buffer"; print OUTF $buffer; } close OUTF;
    and it filled the screen with the stuff you would expect from a binary file. The problems seems to be in line
    open(OUTF, '>', "$directory$filename") || Error;
    It seems that for some reason it does not like the way I am describing or naming the file location.
      read() is a lower level routine and it works with binary. You are just copying raw bits from $fh to OUTF.

      set $fh and OUTF to binary mode by putting this: binmode($fh); binmode(OUTF); before the while statement.

      binmode() a Perl function - read more here: binmode.

      This does not do anything on open() failure:

      open(OUTF, '>', "$directory$filename") || Error;

      This does not define a subroutine:

      Sub Error{ print " error - $! "; }

      This would have helped:

      use warnings; use strict;