I'm struggling with an odd error. I have a simple web app that grabs stuff from a DB then outputs it as a downloadable csv file. It works on firefox and chrome, but IE fails to recognize it as a csv file (thinking it is a html fle) and when I click save I get the error, "Unable to download {name of file} from {name of site}. Unable to open this internet site. ..."
Code:
session_start(); //some logic goes here... //generate csv header header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=exportevent.csv"); header("Pragma: no-cache"); header("Expires: 0"); echo "Event: " . $event_title . "\n"; //print the column names echo "Last Name, First Name, Company \n"; while($row = mysql_fetch_assoc($result)) { echo $row['atlname'] . ',' . $row['atfname'] . ',' . $row['atcompany'] . "\n"; }
I've played around with the content-type a whole bunch, but that had no effect.
Update: I've tried text/csv, application/vnd.ms-excel (and variations of this), text/plain, and some others that I now forget with no luck.
This is IE8 btw.
Update 2: The connection is over SSL.
Via file Explorer View/Options/File Types. Look for CSV file type click Open.
Firefox allows you easily export your saved logins and passwords to a CSV file. It includes the appropriate option in the Logins and Passwords tool, which is also known as Lockwise Password Manager. However, there is no import option visible by default.
Click "File" and "Open," then use the Explorer window to locate the HTML file you want to add the CSV data to. Click the “Open” button.
Don't we love IE? :)
Try using those headers:
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");
I think that the octet-stream content type forces IE to download the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With