【发布时间】:2013-06-11 09:01:12
【问题描述】:
我在从服务器下载 Excel 文件时遇到问题。
excel 文件已经保存在服务器上,我使用下面的代码下载了它。
if(file_exists($reportPath)){
//content type
header('Content-type: application/vnd.ms-excel');
//open/save dialog box
header('Content-Disposition: attachment; filename='.$dirFile[count($dirFile)-1]);
//read from server and write to buffer
readfile($reportPath);
}
但下载的文件已损坏。
我很确定保存在服务器上的文件没有损坏,因为我已经手动将它从服务器获取到我的本地桌面。
意思是,数据已经在运行中被破坏了。
请帮忙,谢谢,我用的是PHP
【问题讨论】:
-
另请注意,我的代码在我们的服务器上正常,但在另一台服务器上运行不佳