解析PHP实现下载文件的两种方法
2013-07-05 00:00
896 查看
方法一:
方法二:
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();
相关文章推荐
- 解析PHP实现下载文件的两种方法
- php 下载保存文件保存到本地的两种实现方法
- 【转】php 下载保存文件保存到本地的两种实现方法
- php 下载保存文件保存到本地的两种实现方法
- php 下载保存文件保存到本地的两种实现方法
- php实现远程网络文件下载到服务器指定目录(方法一)
- php文件上传的两种实现方法
- php实现远程网络文件下载到服务器指定目录(方法一)
- php使用pclzip类实现文件压缩的方法(附pclzip类下载地址)
- PHP实现从远程下载文件的方法
- PHP 中实现文件下载的几种方法
- PHP 文件上传进度条的两种实现方法
- php实现SAE上使用storage上传与下载文件的方法
- PHP实现将多个文件压缩成zip格式并下载到本地的方法示例
- SpringMVC实现文件下载的两种方法
- php实现远程网络文件下载到服务器指定目录(方法二)
- php简单实现文件或图片强制下载的方法
- php实现图片文件与下载文件防盗链的方法
- PHP 文件上传进度条的两种实现方法的代码
- PHP实现打包下载文件的方法示例