Hello, I'm trying to return an image in a cgi script and the code works for jpgs, but not for pngs. Here's the code that works for jpgs:
use strict; print "Content-type: image/jpg\n\n"; my $file_name = "./images/picture.jpg"; binmode IMAGE; binmode STDOUT; open IMAGE, $file_name or die "ERROR $!"; while(read IMAGE, $buff, 1024) { print STDOUT $buff; } close IMAGE; 1;
This returns the image just as I hoped and expected. However, if I merely change the two occurrences of 'jpg' above to 'png', it returns nothing! Both picture.jpg and picture.png exist of course, in the proper place.
I've tried all combinations of with and w/o binmode, a full path to the file, buffering to a temporary variable before printing, etc. and always get the same result. Tested on IE and Chrome.
Any help is greatly appreciated. I've got a fair amount invested in keeping the images as pngs. Thank you.
In reply to Returning jpg works, png NOT by membender
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |