我有以下代码:
$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");
该文件确实位于“uploads”目录中,但我无法在此行代码中正确链接:header('Content-Disposition: attachment; filename="uploads/'.$excel_file.'"');
有关如何设置路径以下载正确文件的任何想法?
感谢。
答案 0 :(得分:0)
用
替换该行header("Content-Disposition: attachment; filename=uploads/".$excel_file.";");
最后,添加以下行
readfile($excel_file);
exit;