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);

 

相关文章:

  • 2022-01-04
  • 2022-12-23
  • 2021-09-17
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-04-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案