我有:
<?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
。