欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP 强制下载文件示例代码

程序员文章站 2022-05-25 10:44:53
...
  1. //php强制下载文件
  2. $filename = '1.png';
  3. header("Content-Type: application/force-download"); //添加强制下载头信息
  4. header('Content-Disposition: attachment; filename="'.$filename.'"');
  5. echo $filename;
  6. ?>
复制代码