我知道有人问过这个问题,但是提供的解决方案对我不起作用。我可以下载pdf文件,但是Adobe Reader告诉我它不是损坏了就是解码不正确。有人有替代的解决方案或可能的修复方法吗?
$path = "http://www.laerdalmail.com/discoversimulation/downloads/needs_assessment_form.pdf";
header('Content-Type: application/pdf');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=needs_assessment_form.pdf");
readfile($path);
exit;
readfile应该被赋予文件系统路径,而不是URL。像这样:
$path = '/websitefolder/discoversimulation/downloads/needs_assessment_form.pdff';
// or
$parh = 'c:'something'needs_assessment_form.pdff';
尝试添加内容长度:
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($path));