PDA

View Full Version : image generated & sent via perl/cgi shows in firefox but not in internet explorer


belphanior
09-23-2007, 10:40 PM
As the topic says, I'm generating an image serverside.
I then open the generated image as $infile and get it's size;
then I send it out like this:


print header(-content_type=>"image/jpg", -content_length=>$size);
while (<$infile>) {
print $_;
}


In Firefox the image shows up fine, but Internet Explorer asks where to save it instead of displaying it.
Any ideas how to get it to show up in IE?

KevinADC
09-24-2007, 12:02 AM
Looks like it should work. Is there more code?

belphanior
09-24-2007, 01:25 AM
No other code that ought to have any influence on how IE handles the response.
First the image is generated according to the request parameters.
The resulting image is in a temp directory used for that purpose.
[The code that generates the image is OK; I can actually view the image with IE by copying it over onto my PC and opening it via the "file" menu.]
After that the tempfile is opened and sent with the bit of code I posted earlier.

Just to increase my confusion a bit more, I have found that it works if I wrap the image with a bit of html:

<html><head></head><body><img src="/url/to/imagegen.pl"></body></html>


This is sufficient to get IE to display the thing. Originally I was just linking to "/url/to/imagegen.pl" directly, because all I really wanted was "a simple testcase" for my script, before I used it from the context of a full html page... HA!

Anyway, having it just work now that I'm not using it "standalone" anymore is nice. Far better than having to perform voodoo rituals and fiddle with response headers in bizarre ways or whatever