[英]Can't download pdf file from server
單擊鏈接時,我試圖強制PDF下載,但我不斷從讀取文件中收到標題警告和奇怪的字符。
<a>
標記:
<p>The pdf file is large and can take a minute to download.
You can <a href="/icisherbrooke/downloadAnnuaire.php">click here to download the pdf.</a></p>
download.php文件:
<?php
$fullpath = 'annuaire_2013-14_optimized3.pdf';
if(file_exists($fullpath)){
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="annuaire_2013-14_optimized3.pdf"');
readfile($fullpath);
exit();
}
?>
當我用echo "test"
替換標題和readfile時,它起作用了。
而不是下載提示,我被重定向到download.php。 這是download.php結果的一部分:
Warning: Cannot modify header information - headers already sent by (output started at /home/kanope/vhost_file/info-rapide.com/icisherbrooke/downloadAnnuaire.php:1) in /home/kanope/vhost_file/info-rapide.com/icisherbrooke/downloadAnnuaire.php on line 8 %PDF-1.6 % 1561 0 obj <> endobj 1575 0 obj <>/Filter/FlateDecode/ID[<0EC5F18608359D479CC3DB0FF72E23C8><997B135B48FBE541BDE876EE8BECFD9D>]/Index[1561 20]/Info 1560 0 R/Length 95/Prev 216592620/
如錯誤所示,在第1行上有一些輸出。通常為空白。 如果看不到任何空格,請檢查BOM。 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.