[請益] 如何對Content-Disposition標頭加下載標題?
<?php
$file="test.pdf";
$url="http://www.example.com/download/";
header("Content-type:application");
header("Content-Disposition: attachment; filename=".$file);
readfile($url.str_replace("@","",$file));
?>
假設我有一個PDF檔叫test.pdf,該檔存在http://www.example.com/download/裡面
今天如果有人點進了這個PHP頁面裡頭,就會自動下載這個PDF檔案
我的這個頁面被Google的「爬蟲」找到了,並被放在他們的搜尋引擎資料庫裡
但是問題在:他們顯示出來的結果標題居然顯示「Untitled」,而且沒有說明內容
明明我原先的PDF檔(test.pdf)有標題啊,
為什麼他們搜尋出來的結果卻是沒有標題和說明內容呢?
請各位幫我解惑一下…
謝謝
---------
實例:
http://www.red-whale.com/download/periodic_table.php
PHP程式碼:
<?php
$file="Periodic_table.pdf";
$url="http://www.red-whale.com/download/";
header("Content-type:application");
header("Content-Disposition: attachment; filename=".$file);
readfile($url.str_replace("@","",$file));
?>
實際PDF檔案:http://www.red-whale.com/download/Periodic_table.pdf
實際PDF檔案標題:元素周期表-A3墊板
Google搜尋該頁面的關鍵字:red whale Untitled
***
輸入完該關鍵字並搜尋之後第一個就是該頁面了,不知道該怎麼為它加標題和說明內容?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.139.104.211
※ 文章網址: https://www.ptt.cc/bbs/PHP/M.1463904141.A.B75.html
※ 編輯: red0whale (101.139.104.211), 05/22/2016 22:08:45
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章