0

我有以下代码:

$objWriter = new PHPExcel_Writer_Excel2007($excel);    
$objWriter->save("uploads/".$excel_file);
header('Content-type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename="uploads/'.$excel_file.'"');
header("Pragma: no-cache");
header("Expires: 0"); 

该文件确实在“上传”目录中,但我无法在这行代码中正确链接它:header('Content-Disposition: attachment; filename="uploads/'.$excel_file.'"');

关于如何设置路径以下载正确文件的任何想法?

谢谢。

4

1 回答 1

0

将该行替换为

header("Content-Disposition: attachment; filename=uploads/".$excel_file.";");

最后,添加以下行

readfile($excel_file);
exit;
于 2013-04-14T18:47:35.840 回答