in reply to Re: Problems Uploadng a file
in thread Problems Uploadng a file

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.

Replies are listed 'Best First'.
Re^3: Problems Uploadng a file
by Marshall (Canon) on Sep 14, 2011 at 00:57 UTC
    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.

Re^3: Problems Uploadng a file
by Anonymous Monk on Sep 14, 2011 at 07:45 UTC

    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;