Last active
August 29, 2015 14:22
-
-
Save ternavsky/ea9787a12b44765f99cf to your computer and use it in GitHub Desktop.
Force download CSV file
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
function forceCSVFileDownload($filename, $csv) { | |
header('Content-Disposition: attachment; filename="'.$filename.'"'); | |
header('Content-Type: csv/plain'); # Don't use application/force-download - it's not a real MIME type, and the Content-Disposition header is sufficient | |
header('Content-Length: ' . strlen($csv)); | |
header('Connection: close'); | |
print($csv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment