-1
我有一个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加入它看起来非常好。问题是什么?
您不必在代码中使用反斜杠。这是完全可以接受的 - 即使是MS Windows - 在路径名中使用正斜杠:'c:/ wamp/dev.solarjoy.com/affiliates/temp/ziplist.csv' – wallyk
添加了什么原始HTML?在文件之前还是之后? –
你能展示一个输出的例子吗? –