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

Posted by Dmytro Shteflyuk on under PHP · Русский (20,168 views)

Today I found very disagreeable 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 only option is 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’ve need sessions! Solution is very simple: it was necessary to add following lines before image output:

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

This 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 19, 2006 at 11:17 am · Permalink

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

said on May 11, 2006 at 9:43 am · Permalink

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

said on March 28, 2007 at 11:55 pm · Permalink

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

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

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

kls
said on April 25, 2007 at 9:38 pm · Permalink

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

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

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

said on October 14, 2007 at 6:28 pm · 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.