作者red0whale (red whale)
看板PHP
标题[请益] 如何对Content-Disposition标头加下载标题?
时间Sun May 22 16:02:15 2016
<?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://webptt.com/cn.aspx?n=bbs/PHP/M.1463904141.A.B75.html
※ 编辑: red0whale (101.139.104.211), 05/22/2016 22:08:45