PHP实现文件强制下载
如果你不希望txt pdf excel在浏览器上查看的话,强制下载吧
<?php $file_dir = "./"; $name = "test.txt"; $file = fopen($file_dir.$name,"r"); Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length: ".filesize($file_dir . $name)); Header("Content-Disposition: attachment; filename=".$name); echo fread($file, filesize($file_dir.$name)); fclose($file); ?>
以上就是PHP实现文件强制下载的内容,更多相关内容请关注PHP中文网(www.php.cn)!