PHP文件流方式輸出文件


1、php輸出文件時候,瀏覽器下載該文件

$file = "./a.png";
header('Content-Disposition:attachment; filename=1.png');
echo file_get_contents($file);

2、PHP輸出圖片,瀏覽器中直接打開圖片

$file = "./a.png";
header('Content-type:image/png');
echo file_get_contents($file);

3、PHP輸出pdf,瀏覽器直接打開pdf

$file = "wangshili.pdf";
header('Content-Type:application/pdf');
echo file_get_contents($file);

 


免責聲明!

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



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