$filename = "test.txt"; header ("Content-Type: application/force-download"); header ('Content-Disposition: attachment;filename="'.$filename.'"'); readfile ($filename); 复制代码 如此便可以实现文件直接下载而非打开。 原理分析: 1,header ("Content-Type: application/force-download"); //强制下载; 2,header ('Content-Disposition: attachment;filename="'.$filename.'"'); //实现文件下载.最后readfile($filename)读取文件进行下载.