下面的代码显示了二进制数据,而不是显示pdf文件的下载对话框。
我做错了什么?
header("Pragma: public");
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Type: application/octet-stream');
header("Content-Disposition: attachment; filename=\"".basename($filepath)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($filepath));
readfile($filepath);
exit
;
already tried application/pdf but no luck !
答案 0 :(得分:1)
将 application / octet-stream 替换为 application / pdf ,然后重试。