in reply to Uploading a file

Okay, now I can upload the file, I can wiew it in the browser (if i just print $buffer)
my $FileHandle = $query->param('bild'); print "$filehandle"; open OUTFILE, '>huvudnyhet.jpg' or die "Couldn't open output file: $ +!\n"; while ($Bytes = read($FileHandle,$Buffer,1024)) { $BytesRead += $Bytes; print OUTFILE $Buffer; } warn "Received $BytesRead bytes"; close OUTFILE;
but the file i save is somehow corrupt, i can not open it either in the browswer or in Photoshop. ('Coud not open the document because of a problem parsing the JPEG data'). Suggestions? :) /wonko

Replies are listed 'Best First'.
(jcwren) RE: Re: Uploading a file
by jcwren (Prior) on Jun 11, 2000 at 18:43 UTC
    I think you need  binmode OUTFILE;after your open statement.


      Thanks! now it works!


      I'm having the same problme but what is binmode OUTFILE;? Robert

        Click this link perlfunc:binmode (or type perldoc -f binmode on your own machine) and read. If the description there does not enlighten you, come back and ask again.

        Nah! You're thinking of Simon Templar, originally played (on UKTV) by Roger Moore and later by Ian Ogilvy
        binmode(OUTFILE) will cause all subsequent reads or writes to and from OUTFILE to be in binary mode. Depending on your system, this may or may not have any effect.
        Check chapter 8 of the Perl Cookbook if you have it handy, or perlfunc