php 強(qiáng)制下載文件實現(xiàn)代碼
更新時間:2013年10月28日 08:43:22 作者:
php 強(qiáng)制下載文件實現(xiàn)代碼。需要的朋友可以過來參考下,希望對大家有所幫助
復(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;
}
?>
?
<?php
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=ins.jpg");
readfile("imgs/test_Zoom.jpg");
?>
相關(guān)文章
PHP使用Mysqli類庫實現(xiàn)完美分頁效果的方法
這篇文章主要介紹了PHP使用Mysqli類庫實現(xiàn)完美分頁效果的方法,結(jié)合實例形式分析了PHP使用Mysqli類庫的相關(guān)配置文件設(shè)置,數(shù)據(jù)庫操作及分頁的相關(guān)實現(xiàn)技巧,需要的朋友可以參考下2016-04-04Mysql的Root密碼忘記,查看或修改的解決方法(圖文介紹)
本篇文章是對關(guān)于Mysql中的Root密碼忘記,查看或修改的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06php 數(shù)學(xué)運算驗證碼實現(xiàn)代碼
php 數(shù)學(xué)運算驗證碼實現(xiàn)代碼2009-10-10