Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Forced file download failing in Internet Explorer
    primarykey
    data
    text
    <p>I have a site where I'm using the following code to force a file download via PHP:</p> <pre><code>$ZipData = file_get_contents($zipFilename); $ZipSize = filesize($zipFilename); header("Content-type: application/octet-stream"); header("Content-disposition: attachment; filename=".$ZipTitle.".zip"); echo $ZipData; </code></pre> <p>While this works perfectly in Chrome and Firefox, it simply does nothing in Internet Explorer. While Googling I found a potential solution and changed the code to as follows:</p> <pre><code>$ZipData = file_get_contents($zipFilename); $ZipSize = filesize($zipFilename); if (strstr($HTTP_USER_AGENT,"MSIE")){ header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-type: application-download"); header("Content-Length: $ZipSize"); header("Content-disposition: attachment; filename=".$ZipTitle.".zip"); header("Content-Transfer-Encoding: binary"); }else{ header("Content-type: application/octet-stream"); header("Content-disposition: attachment; filename=".$ZipTitle.".zip"); } echo $ZipData; </code></pre> <p>But still no luck. I don't know why it's failing, nor where to start looking for errors or problems, is this just some I.E. bug I'm unaware of? Where should I start trying to find a solution?</p> <p>Note: $ZipTitle will always be 'TexturePacker_Pack_xxx' where xxx is an incremented number. $ZipFilename is an existing zip file which is unlinked AFTER the file is sent to the browser.</p> <p>Edit: The site and code in question are in action on <a href="http://www.texturepacker.net" rel="nofollow">http://www.texturepacker.net</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload