Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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;


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.
      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.

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

        Thanks anyways.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://95058]
Approved by root
talexb finishes writing a Cranky Old Man post, and hopes it will be taken in the spirit intended. :)
[Corion]: We're happy to have you here, talexb!
[talexb]: Thanks. :)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2018-07-19 14:15 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (409 votes). Check out past polls.