if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: " /> 综合国产精品,成人一区福利,国产乱人伦偷精品视频免下载

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php下載文件的代碼示例

復制代碼 代碼如下:
<?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;
}
?>

以上代碼是下載代碼
接下來貼一段在線預覽pdf文件的代碼
復制代碼 代碼如下:
<?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.');
}
}
?>

php技術php下載文件的代碼示例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 宜都市| 洛隆县| 晋江市| 阿瓦提县| 蓝山县| 铁岭市| 尚义县| 金溪县| 化州市| 滨州市| 铜鼓县| 沭阳县| 兴安县| 潜江市| 霍州市| 博乐市| 伊宁县| 宁河县| 营山县| 宁乡县| 宜兴市| 灌阳县| 左云县| 泸州市| 建宁县| 长宁区| 安阳县| 山西省| 都匀市| 武威市| 荣成市| 乌拉特中旗| 甘南县| 垫江县| 喀喇| 中超| 新昌县| 旬邑县| 右玉县| 兴海县| 鄄城县|