if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: " /> 国产裸体写真av一区二区,国产日韩欧美一区二区三区综合 ,亚洲欧美亚洲

色尼玛亚洲综合影院,亚洲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下載文件的代碼示例,轉載需保留來源!

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

主站蜘蛛池模板: 大庆市| 元阳县| 连城县| 灵丘县| 高邑县| 兴和县| 大名县| 青铜峡市| 连城县| 大余县| 忻州市| 高阳县| 吴旗县| 兴业县| 葫芦岛市| 仲巴县| 长泰县| 湘乡市| 哈巴河县| 清徐县| 专栏| 清苑县| 和林格尔县| 九寨沟县| 波密县| 西昌市| 蕉岭县| 龙口市| 达拉特旗| 东光县| 辰溪县| 泽州县| 慈利县| 达日县| 讷河市| 灵川县| 卢氏县| 柳州市| 临颍县| 昌邑市| 扎兰屯市|