Russell <nu**@null.noemail> wrote in message news:<xk*****************@news-binary.blueyonder.co.uk>...
Hi,
I'm using php to generate a csv file and want to force the user to
download it to their local PC.
Trouble is, when I use:
header("Content-Disposition: attachment; filename=\"download.csv\"");
the browser wants to save the file as download.csv.php
Any suggestions as to how I can get rid of the .php? I'd rather not tell
apache that it should pass csv files through php.
IE needs specific headers. Always refer manual before posting any
questions
http://in.php.net/header
<?php
$file_name = 'xx.csv';
header('Content-Type: text/comma-separated-values');
//IE need specific header...
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{
header('Content-Disposition: inline; filename="'.$file_name.'"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
}
else
{
header('Content-Disposition: attachment;
filename="'.$file_name.'"');
header('Pragma: no-cache');
}
?>
---
"Dying is an art, like everything else"---Sylvia Plath
Email: rrjanbiah-at-Y!com