Created
August 17, 2015 15:18
-
-
Save SmetDenis/0b7b04c9a6b0a88887e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// no cache | |
if (!headers_sent()) { | |
header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); | |
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | |
header('Cache-Control: no-cache, must-revalidate, max-age=0'); | |
header('Pragma: no-cache'); | |
} | |
// download | |
if (!headers_sent()) { | |
// Required for some browsers | |
if (ini_get('zlib.output_compression')) { | |
@ini_set('zlib.output_compression', 'Off'); | |
} | |
header('Pragma: public'); | |
header('Expires: 0'); | |
header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); | |
// Required for certain browsers | |
header('Cache-Control: private', false); | |
header('Content-Disposition: attachment; filename="' . basename(str_replace('"', '', $filename)) . '";'); | |
header('Content-Type: application/force-download'); | |
header('Content-Transfer-Encoding: binary'); | |
if ($content) { | |
header('Content-Length: ' . strlen($content)); | |
} | |
ob_clean(); | |
flush(); | |
if ($content) { | |
echo $content; | |
} | |
} | |
// utf8 | |
if (!headers_sent()) { | |
header('Content-type: text/html; charset=utf-8'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment