Created
July 1, 2015 09:12
-
-
Save Werninator/8c31374b764fea2b534f to your computer and use it in GitHub Desktop.
Forced Downloads mit PHP
This file contains hidden or 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 | |
$filename = 'mein-export.csv'; | |
$content = '1,2,3,4,5'; | |
// Header setzen | |
header("Pragma: public"); | |
header("Expires: 0"); | |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); | |
header("Cache-Control: private", false); | |
header("Content-Type: application/octet-stream"); | |
header("Content-Disposition: attachment; filename=\"$filename\";" ); | |
header("Content-Transfer-Encoding: binary"); | |
// Content ausgeben | |
echo $content; | |
// Wichtig: die() - sonst gibt's ne Weiterleitung. | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment