php实现下载
来源:互联网 发布:夏威夷旅行社 知乎 编辑:程序博客网 时间:2024/06/07 01:55
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($filepath);
public function downloadFile($file_name){ $fileinfo = pathinfo($file_name); $file_path=realpath($file_name); header('Content-type: application/x-'.$fileinfo['extension']); header( "Accept-Ranges: bytes "); header('Content-Length: '.filesize($file_path)); header('Content-Disposition: attachment; filename='.$fileinfo['basename']); readfile($file_path); } public function downloadFileCopy() { header("Content-type:text/html;charset=utf-8"); $file_name="Public/csv/导入学生模板表格.csv"; $file_name=iconv("utf-8","gb2312",$file_name); $file_path=$file_name; if(!file_exists($file_path)){ echo "没有该文件文件"; return ; } $fp=fopen($file_path,"r"); $file_size=filesize($file_path); $file_name = '导入学生模板表格.csv'; Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length:".$file_size); Header("Content-Disposition: attachment; filename=".$file_name); $buffer=1024; $file_count=0; while(!feof($fp) && $file_count<$file_size){ $file_con=fread($fp,$buffer); $file_count+=$buffer; echo $file_con; } fclose($fp); }
下载中文文件名
0 0
- PHP实现文件下载
- 用 PHP 实现下载
- PHP实现文件下载
- PHP实现文件下载
- PHP实现文件下载
- PHP实现下载功能
- php实现下载
- PHP实现断点下载
- php 实现定时下载
- php实现文件下载
- PHP实现文件下载
- php实现文件下载
- php实现文件下载
- php实现文件下载
- php 实现下载文件
- PHP实现文件下载
- php实现文件下载
- php实现下载
- Android studio 导入github工程
- 同步mysql数据到ElasticSearch的最佳实践
- 8.java网络编程
- github使用学习
- 关于Android wifi通信笔记
- php实现下载
- java8实现spark streaming的wordcount
- android动态创建UI备忘
- 第16周项目1 验证算法(4)快速排序
- 第十四周项目1(1)--验证折半查找算法
- streamsets Data Collecotor启动流程分析
- 第15周项目3-B-树的基本操作
- Spring+Websocket实现消息的推送
- 51Nod-1534-棋子游戏