我有一个csv
文件,只有一行保存在我系统的临时位置
我只想使用php
下载文件
当我从临时位置打开但是使用代码
$file = 'c:\\wamp\\dev.solarjoy.com\\affiliates\\temp\\ziplist.csv';
if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
exit;
}
else
{
echo 'file does not exist';
}
该文件将原始html添加到其中。有什么问题?
答案 0 :(得分:0)
I figured out the solution, I was putting the fileread code after the head tag, so for some reason readfile was inserting it in the file (should not happen that way though) so I moved the code at top of the page and it fixed it.