carlg Posted October 22, 2007 Share Posted October 22, 2007 What is the best way to have a user download a csv file? I can create the file, but when the user clicks on a link to the file it actually displays the file in the browser. I want it to have the popup box where it says "Where do you want to save this file?" and allows the user to save it. How can I do this? Thanks Carl Link to comment https://forums.phpfreaks.com/topic/74383-user-downloads-a-csv-file/ Share on other sites More sharing options...
trq Posted October 22, 2007 Share Posted October 22, 2007 Check out the FAQ/Code snippet repository. There is a force download thread in there. Link to comment https://forums.phpfreaks.com/topic/74383-user-downloads-a-csv-file/#findComment-375820 Share on other sites More sharing options...
Orio Posted October 22, 2007 Share Posted October 22, 2007 The phrase you are looking for is "force download". Check this: http://elouai.com/force-download.php Orio. Link to comment https://forums.phpfreaks.com/topic/74383-user-downloads-a-csv-file/#findComment-375821 Share on other sites More sharing options...
Barand Posted October 22, 2007 Share Posted October 22, 2007 this works for me <?php header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=aaa.csv"); header("Pragma: no-cache"); header("Expires: 0"); echo "a,b,1\n"; echo "d,e,2\n"; ?> Link to comment https://forums.phpfreaks.com/topic/74383-user-downloads-a-csv-file/#findComment-375824 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.