剖析PHP实现下载文件的两种方法
发布时间:2023-12-20 16:02:58 所属栏目:PHP 来源:DaWei
导读: 本篇文章是对使用PHP实现下载文件的两种方法进行了详细的分析介绍,需要的朋友参考下
方法一:
复制代码 代码如下:
header('Content-Description: File Tra
方法一:
复制代码 代码如下:
header('Content-Description: File Tra
本篇文章是对使用PHP实现下载文件的两种方法进行了详细的分析介绍,需要的朋友参考下 方法一: 复制代码 代码如下: header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($filepath)); header('Content-Transfer-Encoding: binary'); header('Expires: 0′); header('Cache-Control: must-revalidate, post-check=0, pre-check=0′); header('Pragma: public'); header('Content-Length: ' . filesize($filepath)); readfile($file_path); 方法二: 复制代码 代码如下: $fileinfo = pathinfo($filename); header('Content-type: application/x-'.$fileinfo['extension']); header('Content-Disposition: attachment; filename='.$fileinfo['basename']); header('Content-Length: '.filesize($filename)); readfile($thefile); exit()。 (编辑:4S站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐