I can get the file to write to the server perfectly. What I am wanting to do is to have it download automatically through the browser - which it does - but the file is unreadable. I think I have been stuck on this so long I’ve forgotten knowledge and started throwing darts. Here is what I have now:
[php]$NewFile = fopen($FileName,“w”);
fwrite($NewFile, $output);
header(‘Content-Type: text/csv; charset=utf-8’);
header(‘Content-Disposition: attachment; filename="’.$FileName.’"’);
fclose($NewFile);
header('Content-Length: '.filesize($FileName));[/php]
The above is from asking some other people and here is what I started with. Both yield the same results:
[php]$NewFile = fopen($FileName,“w”);
fwrite($NewFile, $output);
fclose($NewFile);
//print_r($output);
header(‘Content-type: text/csv; charset=UTF-8’);
header(“Content-type: application/force-download”);
header(‘Content-Description: File Transfer’);
header(‘Content-Disposition: inline; filename="’.$NewFile.’"’);
header(“Content-length: “.filesize($NewFile));
//header(‘Content-Type: text/csv’);
header('Content-Disposition: attachment; filename=”’.$FileName.’”’);
readfile($NewFile);
@unlink($FileName);[/php]
Both write a file to the server that opens fine in OpenOffice as a CSV from the server or FTP but the file which downloads through the browser is encoded - not sure how. It looks like this: ��ࡱ�