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