输入banner图图片脚本导航/分类

PHP强制下载文件方法浅析

  1. $filename = "test.txt";
  2. header ("Content-Type: application/force-download");
  3. header ('Content-Disposition: attachment;filename="'.$filename.'"');
  4. readfile ($filename);

如此便可以实现文件直接下载而非打开。

原理分析: 1,header ("Content-Type: application/force-download"); //强制下载; 2,header ('Content-Disposition: attachment;filename="'.$filename.'"'); //实现文件下载.最后readfile($filename)读取文件进行下载.