错误:在MAC上将pdf文件转换为txt


ERROR: pdf file being converted to txt on MAC

我有:

<?php 
 header('Content-type: text/plain');
 header('Content-Disposition: attachment; filename="test filename.pdf"');
 readfile('test filename.pdf');
?>

这在Windows上下载pdf文件很好,但当涉及到Mac时,它会将pdf文件转换为.txt,从而在下载时转换为filename.pdf.txt;现在无法读取该文件。Mac为什么这么做?

因为mimetype是一个TXT文件。您需要将mimetype设置为application/pdf