Written by Nabil Sadki | Published in Code snippets
Sometimes we need to generate a CSV file dynamically, and launch it as downloadable file, it works fine in Firefox, Opera, Chrome and other guru browsers, but when we talk about Internet Explorer, maybe we need to hack the code.
By googling a little, i found an easy solution, so in php, we can do it like this :
1 2 3 4 5 6 7 8 9 |
<?php 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=\"exportevent.csv\";" ); header("Content-Transfer-Encoding: binary"); ?> |