<?
session_start();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: text/comma-separated-values");
header("Content-Disposition: attachment; filename=\"results.csv\"");
$i = $_SESSION['allresults_count'];
$array = $_SESSION['allresults'];
$a = 0;
echo("Rec Number,Sales,Employees,Sic,Sic extention,Name,State,Zip,Zip extention,County,Census Tract,Bank Fimp,Branch\n");
while($a < $i)
{
reset($array[$a]);
while(list($key, $val) = each($array[$a]))
{
echo('="' . $val . '"');
echo(",");
}
echo("\n");
$a++;
}
?>
I'm using this to generate a .cvs file on the fly to be downloaded from data collected in $_SESSION['allresults'].... IE handles it fine, but netscape wants to add a .php so it becomes results.cvs.php... I am using the same set of headers as I use for downloading .xls files (obviously Content-Type is different, but otherwise the same) so I was wondering if anyone knew what is causing this.
Netscape downloading with a .php extension added on to file
Moderator: General Moderators
-
Ryan Frank
- Forum Newbie
- Posts: 2
- Joined: Wed Feb 18, 2004 3:50 pm
I use this in my header:
I have no ''s or "'s around my page name
Does this make a difference ?
Code: Select all
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=page_name.csv");
header("Content-Transfer-Encoding: binary");
?>Does this make a difference ?
-
Ryan Frank
- Forum Newbie
- Posts: 2
- Joined: Wed Feb 18, 2004 3:50 pm
Doesnt appear to do anything.... thanks for the reply though.
Netscape is definately getting the content-type correctly as the dialog box says "result.cvs.php is of type text/comma-separated-values (or application/octet-stream if i use that) but still insists on adding .php to the filename.... still confused as why it works when the content-type is for ms .xls files.
Netscape is definately getting the content-type correctly as the dialog box says "result.cvs.php is of type text/comma-separated-values (or application/octet-stream if i use that) but still insists on adding .php to the filename.... still confused as why it works when the content-type is for ms .xls files.