Jump to content

GD Library - Saving images in IE


paniwani

Recommended Posts

My site dynamically creates a jpeg image using the GD library and I access the image through an <img> tag inside the main page. My problem is that when I try to right click on and save the image in internet explorer, the file is saved as a .bmp file instead of .jpeg. Firefox and opera both correctly save as .jpeg. I think this might be an issue of using the right headers, but I'm not sure how they work exactly. Right now, these are the headers on my image page:

 

header("Content-Type: image/jpeg");

header("Content-Disposition: inline; filename=graphicschedule;");

 

How do I get IE to save the file correctly as a jpeg? Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/118580-gd-library-saving-images-in-ie/
Share on other sites

The file name also needs quotes around it and no semi-colon at the end. Untested (I am not sure this will fix your problem, but it corrects the syntax) -

 

header('Content-Disposition: inline; filename="graphicschedule.jpg"');

Thanks for the advice guys. I read online that in order for IE to display the .jpeg properly I had to utilize the cache. Now as far as I know, that means the user will download a local copy of the web page to their hard drive so they can access it quicker next time. Can anyone explain why IE needed that or just explain cache better? Here's my working code:

 

header("Content-Type: image/jpeg");

header('Content-Disposition: inline; filename="graphicschedule.jpg"');

session_cache_limiter('public');

 

also, in my image tag i added a random number suffix to the page so it would cache a different page each time:

 

echo "<img src='image.php/" . mt_rand(1,100000) . "'>";

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.