リンクがクリックされたときに PDF を強制的にダウンロードしようとしていますが、readfile からヘッダーの警告と奇妙な文字が表示され続けます。
<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();
}
?>
ヘッダーと readfile を に置き換えると、echo "test"
機能します。
ダウンロード プロンプトの代わりに、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/