IE closes windows immediately when download starts
-
02-06-2021 - |
Question
I have a PHP script which downloads files to the client, in a new window. It works great in firefox, but in IE8 the window opens and then closes immediately. Note this ONLY happens for some files (like text/plain type), but for others (eg: application/pdf) it works fine.
My PHP script adds the http headers shown below (plus a few added by my proxy server are shown). I can't figure out what's wrong. After playing with headers in php I find that removing Content-Type and Content-Disposition seems to have an impact, but I'm just messing around and can't really understand what's wrong.
I grabbed the header from Firefox as shown below. Can anyone see something which would cause IE to close immediately I tried setting the mime type to application/text but no difference.
HTTP/1.0 200 OK
Date: Sat, 21 Apr 2012 21:02:13 GMT
Server: Apache
Pragma: public
Expires: 0
Cache-Control: public
Content-Description: File Transfer
Content-Disposition: attachment; filename="Sample_Text_File.txt"
Content-Transfer-Encoding: binary
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 47
Content-Type: text/plain
X-Cache: MISS from firewall.mydomain.ca
X-Cache-Lookup: MISS from firewall.mydomain.ca:3128
Via: 1.0 firewall.mydomain.ca (squid/3.0.STABLE7)
Proxy-Connection: close
Solution 2
It appears to be IE's anti-popup technology. Even though I marked the site as sage in IE's settings, it still blocks..
Solution was to start the download in the same windows (not _blank) and the IE is happy. Every other browser I you can open in a new window.
OTHER TIPS
I would start by removing all unneeded response headers, in particular non-sensical ones such as Content-Transfer-Encoding and Content-Description.
A potential reason might be broken caching information, or IE's inability to handle many types of the Vary response header properly.