Why does IE save pictures from the Web in bitmap format?

Posted by Dmytro Shteflyuk on under PHP

Today I found very strange problem with Internet Explorer. I’ve generated GIF-image with PHP GD2 and sent results for client browser. In IE I’ve tried to store picture in my local file system but the only option was to save the picture as a .BMP file instead of as a native .gif file! The same problem is described in Microsoft Knowledge Base, but it does not help me.

Then I start playing with PHP and headers and discover very nice gizmo: bug became apparent only when my PHP-script uses session_start(). But I needed sessions! Solution was very simple: it was necessary to add following lines before image output:

1
2
3
header("Cache-Control:");
header("Pragma:");
header("Set-Cookie:");

These lines will clear all headers sent by session_start() function and IE will understand that your the image is in right format.

7 Responses to this entry

Subscribe to comments with RSS

erka
said on January 19th, 2006 at 11:17 · Permalink

угу, видел такое. но не игрался для устранения ошибки. спасибо за исследование и решение проблемы

said on May 11th, 2006 at 09:43 · Permalink

Спасибо! Сегодня наткнулся и был очень рад, что знаю, где брать ответ. :-)

said on March 28th, 2007 at 23:55 · Permalink

Very useful and interesting aricle. Can I translate and insert this on my site?
Greetings
Aukcje

said on March 29th, 2007 at 11:18 · Permalink

Of course you can. Just don’t forget to insert link to original one.

kls
said on April 25th, 2007 at 21:38 · Permalink

спасибо большое за решение… :)

dkrnl
said on July 21st, 2007 at 21:00 · Permalink

тоже намучался с этим – наткнулся на ваш пост.
решение есть более элегантное:
session_cache_limiter(‘none’)

said on October 14th, 2007 at 18:28 · Permalink

session_cache_limiter(’none’)
если можно обьясните новичку

Comments are closed

Comments for this entry are closed for a while. If you have anything to say – use a contact form. Thank you for your patience.