最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php下載文件的代碼示例

 更新時(shí)間:2012年06月29日 14:32:13   作者:  
php下載文件的代碼示例,需要的朋友可以參考下
復(fù)制代碼 代碼如下:

<?php
$file = 'monkey.gif';

if (file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
?>

以上代碼是下載代碼
接下來貼一段在線預(yù)覽pdf文件的代碼
復(fù)制代碼 代碼如下:

<?php
public function fddAction()
{
// get attachment location
$attachment_location = $_SERVER["DOCUMENT_ROOT"] . "/pdf/fdd/sample.pdf";

if (file_exists($attachment_location)) {
// attachment exists

// send open pdf dialog to user
header('Cache-Control: public'); // needed for i.e.
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="sample.pdf"');
readfile($attachment_location);
die(); // stop execution of further script because we are only outputting the pdf

} else {
die('Error: File not found.');
}
}
?>

相關(guān)文章

最新評論

邮箱| 东方市| 蓝田县| 拉萨市| 铜梁县| 余庆县| 平陆县| 阜新市| 运城市| 泾川县| 东乡| 正宁县| 浦县| 阿荣旗| 荣昌县| 英超| 三原县| 大安市| 雷山县| 邹城市| 清苑县| 眉山市| 沽源县| 九江县| 铜梁县| 天峻县| 清镇市| 武隆县| 天等县| 青铜峡市| 台山市| 新巴尔虎左旗| 垫江县| 嘉义市| 民和| 新余市| 长岭县| 孙吴县| 福贡县| 利川市| 上林县|