Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Image Corruption?

by Anonymous Monk
on Jul 09, 2001 at 21:05 UTC ( #95058=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a script that I think works because the file gets uploaded, has correct size, etc. but when I go to look at that file it must be corrupted or something as it shows up only as a little red x as the picture. Here is the code that I am using, please let me know what's missing.
#UPLOAD THE FILE/PICTURE my $outfile ="/home/path/$tempID.jpg"; open(OUT,">$outfile") || die "Could not read $outfile, $!"; my $data; my $size = 0; my $total_size = 0; binmode $file; binmode OUT; while ($size = read($file,$data,16384)) { print OUT $data; $total_size += $size; } close OUT;


Thanks.

Replies are listed 'Best First'.
Re: Image Corruption?
by gornox_zx (Priest) on Jul 10, 2001 at 18:38 UTC
    When uploading images they need to be transferred in BINARY mode. If you upload in ASCII, the images will deffinately be corrupted.
    ~heise2k~
      You are correct. Image corruption is caused by uploading via FTP on ASCII mode. Binary makes sense.
Re: Image Corruption?
by Hero Zzyzzx (Curate) on Jul 09, 2001 at 21:23 UTC

    What directory are you trying to upload the picture to? The cgi-bin directory? If so, you might not be able to view images stored there. Can you post more complete code?

    Are you sure the HTML that creates the IMG tag is pointing to the proper directory / file?

      The directory that I am uploading it to is not the cgi-bin directory. I have other pictures in there that I have ftped to there and have no problems with them.

      I have tried to check the file by ftping in back down to my Windows pc using an ftp program. The file has a size but can't be seen.

      This code is coming from a huge file which is why i have only posted the code related to the file upload for you. If you could hint at what other portions would be helpful for you I will put those up as well.

      Thanks.
        Never mind, I got it figured out. Wrong settings on my ftp program. Works fine.

        Thanks anyways.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://95058]
Approved by root
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-16 07:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (449 votes). Check out past polls.

    Notices?