php 強制下載文件實現(xiàn)代碼
更新時間:2013年10月28日 08:43:22 作者:
php 強制下載文件實現(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)文章
無刷新動態(tài)加載數(shù)據(jù) 滾動條加載適合評論等頁面
無刷新動態(tài)加載數(shù)據(jù),滾屏加載更多數(shù)據(jù),適合評論等頁面,具體實現(xiàn)如下,感興趣的朋友可以參考下2013-10-10
PHP實現(xiàn)二維數(shù)組按某列進行排序的方法
這篇文章主要介紹了PHP實現(xiàn)二維數(shù)組按某列進行排序的方法,結(jié)合實例形式分析了php二維數(shù)組排序的技巧,涉及array_multisort函數(shù)的使用方法,需要的朋友可以參考下2016-11-11
php創(chuàng)建多級目錄與級聯(lián)刪除文件的方法示例
這篇文章主要介紹了php創(chuàng)建多級目錄與級聯(lián)刪除文件的方法,結(jié)合實例形式分析了php使用mkdir創(chuàng)建多級目錄與unlink結(jié)合rmdir遞歸刪除多級目錄相關(guān)操作技巧,需要的朋友可以參考下2019-09-09

