File Download Dialog



Hi

I can't seem to get the file download dialog to appear, the code I'm using
is below, any ideas very welcome!! All that happens is that the csv text
appears in the browser window.

<?php
include 'config.php';
include 'opendb.php';

$query="select * from atable";
$result = mysql_query($query) or die(mysql_error());

$csv = array();
$html = array();
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
$csv[] = implode(",", $row);
$html[] = "<tr><td>" .implode("</td><td>", $row) . "</td></tr>";
}


$tsv = implode("\r\n", $csv);
$html = "<table>" . implode("\r\n", $html) . "</table>";

$fileName = 'DBDownload.csv';
//header("Content-type: text/plain");
header("Content-type: application/x-msdownload");
header("Content-Disposition: attachment; filename=$fileName");
print $tsv;
exit;
?>

Thanks in advance

Pat Buxton




.



Relevant Pages

  • File Download dialog problem
    ... I can't seem to get the file download dialog to appear, ... $csv = array; ... Pat Buxton ...
    (alt.php)
  • Re: File Download dialog problem
    ... Sorry, should have clarified, the output is just output to the browser as ... I can't seem to get the file download dialog to appear, ... Pat Buxton ...
    (alt.php)
  • File Download
    ... file download dialog prompting a user to save in csv or xls format. ... Below is the relevant code. ...
    (microsoft.public.vsnet.general)
  • File Downloads
    ... file download dialog prompting a user to save in csv or xls format. ... Below is the relevant code. ...
    (microsoft.public.dotnet.general)