怎样做到点击一个PDF文件的链接后提示下载保存文件
我的网页上有一个"下载"的按钮, 需要下载的文件是pdf格式的,我想知道如何做到下载而不是直接打开呢?
多谢 <?php$filename = "document.pdf";header('Content-Type: application/octet-stream');header('Content-Disposition: attachment; filename=' . $filename);?>
这样用浏览器打开之后,就可以下载document.pdf。 http://www.phpv.net/html/1675.html
这样用浏览器打开之后,就可以下载document.pdf。
neversaylate 发表于 2009-5-5 16:30 http://codeigniter.org.cn/forums/images/common/back.gif
多谢, 真的很好用呢....:victory: <?php
$filename = "download/simfin.pdf";
$fp = fopen($filename, "r");
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);
echo fread($fp,filesize($filename));
fclose($fp);
?> 主要是这句“'Content-Disposition: attachment”,了解一下http协议,有很多有趣的东西
页:
[1]