not sure if you already have the answer to this one but you:

binmode IMAGE;
print "Content-type: image/jpeg\n\n";
while(<IMAGE>){
    print;
}

should probably be:

print "Content-type: image/jpeg\n\n";
binmode IMAGE;
while(<IMAGE>){
    print;
}

you need to print the text header first and than print the 
binary image. try it and see if it works or not.

alos, use "\n\n" is better than "\r\n\r\n" because "\n\n" is more
portable. you also don't need to binmode STDOUT

david

Perl wrote:

> Hello All,
> 
> I created a simple http upload file routine that uploads file into my
> accounts sub folder uploads, "/home/myaccount/uploads". This is
> already running.
> 
> Now what I wanted to do is retrieve the uploaded file from the
> browser, and display the content in the browser if it is an image or
> a text/html file, if not then download it. I made a simple code and
> its not working for the image file, I hope someone here in the list can
> help me.
> 
> Here are the sample code that I've tried so far and it didn't work.
> Kindly please tell me what I missed....
> 
> 
> Code 1: It didnt work...
> 
> #!/usr/bin/perl
> 
> use CGI;
> $query = new CGI;
> my $filepath='/home/myaccount/uploads/laptop.jpg';
> 
> print $query->header('image/jpeg');
> print $filepath;
> 
> 
> Code 2: This code is running ok with text/html files, but not with the
> images, I hope someone here can help me.
> 
> 
> #!/usr/bin/perl
> 
> my $filepath="/home/rce/uploads/drugs.jpg";
> 
> open(IMAGE, $filepath);
> binmode IMAGE;
> 
> print "Content-type: image/jpeg\n\n";
> while(<IMAGE>){
>          print;
>     }
> 
> 
> 
> Thanks in advance
> 
> Archie


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to