.PDF ファイルにリンクする代わりに、次のようなことを行います。
<a href="pdf_server.php?file=pdffilename">Download my eBook</a>
これは、カスタム ヘッダーを出力し、PDF (バイナリセーフ) を開き、データをユーザーのブラウザーに出力します。ユーザーは、ブラウザーの設定に関係なく、PDF を保存することを選択できます。pdf_server.php は次のようになります。
header("Content-Type: application/octet-stream");
$file = $_GET["file"] .".pdf";
header("Content-Disposition: attachment; filename=" . urlencode($file));
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Length: " . filesize($file));
flush(); // this doesn't really matter.
$fp = fopen($file, "r");
while (!feof($fp))
{
echo fread($fp, 65536);
flush(); // this is essential for large downloads
}
fclose($fp);
PS: 明らかに、「ファイル」変数に対していくつかの健全性チェックを実行して、ファイル拡張子を受け入れない、スラッシュを拒否する、値に .pdf を追加するなど、人々がファイルを盗むのを防ぎます。