欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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;
}
?>

以上代碼是下載代碼
接下來(lái)貼一段在線預(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)文章

  • Yii2框架dropDownList下拉菜單用法實(shí)例分析

    Yii2框架dropDownList下拉菜單用法實(shí)例分析

    這篇文章主要介紹了Yii2框架dropDownList下拉菜單用法,結(jié)合實(shí)例形式分析了Yii框架中dropDownList下拉菜單的定義、實(shí)現(xiàn)方法與使用技巧,需要的朋友可以參考下
    2016-07-07
  • PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼

    PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼

    這篇文章主要介紹了PHP 使用位運(yùn)算實(shí)現(xiàn)四則運(yùn)算的代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • 最新評(píng)論