Skip to content

Instantly share code, notes, and snippets.

@EricYue2012
Created November 22, 2013 05:12
Show Gist options
  • Save EricYue2012/7595171 to your computer and use it in GitHub Desktop.
Save EricYue2012/7595171 to your computer and use it in GitHub Desktop.
PHP: force browser download file
header("Pragma: public");
header("Expires: 0");
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header('Content-disposition: attachment; filename=' . '1006_3d-HK-Flag.png');
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' . filesize(WWW_ROOT.'/feedback_files/1006_3d-HK-Flag.png'));
@readfile(WWW_ROOT.'/feedback_files/1006_3d-HK-Flag.png');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment