pthurmond Posted December 1, 2008 Share Posted December 1, 2008 I am working on creating an automatic CSV file output system for one of my admin pages and I have it most of the way there. The problem I am running into is that when the download comes up the file extension is no longer on the name, even though it is in the filename section of the header. So I get a file name with no extension on it. I just want to add the ".csv" part to the end. With the way it currently is I have to manually type the file extension in the dialog box. Below is a sample of my headers... //Outputs the CSV file as a page. Just call this and it will do the rest. function return_file($filename = 'Output') { header("Expires: 0"); header("Cache-control: private"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Description: File Transfer"); //header("Content-Type: application/vnd.ms-excel"); //header("Content-type: text/plain"); header("Content-type: text/x-csv"); header("Content-disposition: attachment; filename=" . $filename . ".csv"); echo $this->file; exit(); } As you can see I have tried several content types in the hopes that the change would solve the problem. However, it did not work. I am new to creating dynamic file downloads so I am probably missing something obvious. Thanks, Patrick Link to comment https://forums.phpfreaks.com/topic/135053-file-output-not-retaining-file-extension/ Share on other sites More sharing options...
MatthewJ Posted December 1, 2008 Share Posted December 1, 2008 header("Content-disposition: attachment; filename = $filename.csv"); It works for me anyway Good luck Link to comment https://forums.phpfreaks.com/topic/135053-file-output-not-retaining-file-extension/#findComment-703450 Share on other sites More sharing options...
pthurmond Posted December 1, 2008 Author Share Posted December 1, 2008 Actually I just figured out that it was how Firefox 3 was handling it. The output doesn't have that problem with IE. I wonder if this could be considered a browser bug or it just needs something else. Link to comment https://forums.phpfreaks.com/topic/135053-file-output-not-retaining-file-extension/#findComment-703468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.