php實現圖片下載


download.php下載代碼

1 <?php
2 //獲取要下載的文件名
3 $filename = $_GET['filename'];
4 //設置頭信息
5 header('Content-Disposition:attachment;filename=' . basename($filename));
6 header('Content-Length:' . filesize($filename));
7 //讀取文件並寫入到輸出緩沖
8 readfile($filename);

Html調用

<a href="download.php?filename=./files/test1.jpg">下載圖片</a>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM