Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Uploading a file

by wonko (Pilgrim)
on Jun 11, 2000 at 18:33 UTC ( #17597=note: print w/replies, xml ) Need Help??

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://17597]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2020-10-19 15:44 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (205 votes). Check out past polls.