Download file in IE from HTTPS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rizjav_86
Forum Newbie
Posts: 16
Joined: Wed Feb 24, 2010 10:09 am

Download file in IE from HTTPS

Post by rizjav_86 »

I am creating excel files on the fly from my code and then I give a "download" button to users to download the newly created excel file. Everything works fine on all the modern browsers except IE. It gives an error message that "Unable to open this internet site. The requested site is either unavailable or cannot be found. Please try again later"

I have googled this issue and it seems like that IE throws this error for HTTPS (SSL) URLs. microsoft support page says that it can happen if you have any of the following headers:
Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate
In my code I don't have these headers, but when I print the headers from PHP these get included automatically, I also tried to use unset() to get rid of them but still no luck, any help is appreciated. Here is my code below:

Code: Select all

		header("Content-Disposition: attachment; filename=$filename"); 
		header("Content-Type: application/vnd.ms-excel");  

                echo $data;
rizjav_86
Forum Newbie
Posts: 16
Joined: Wed Feb 24, 2010 10:09 am

Re: Download file in IE from HTTPS

Post by rizjav_86 »

ok I found the solution, adding the following two headers does the trick in IE.

Code: Select all

		header('Pragma: private');
		header('Cache-control: private, must-revalidate');
Post Reply