php 实现下载文件
来源:互联网 发布:淘宝网颜色分类 编辑:程序博客网 时间:2024/05/12 21:41
class DownLoadFile{public static function DownLoadFile1($filename){$file_name=iconv("utf-8", "gb2312", $filename);if (!file_exists($filename)){echo "文件不存在!";return;}$handle=fopen($filename, "r");$filesize=filesize($filename);header("Contect-type: application/octet-stream");header("Accept-Ranges: bytes");header("Accept-Length: $filesize");header("Content-Disposition: attachment; filename=$filename");$length = 1024;$filecount=0;while (!feof($handle) && ($filesize-$filecount)>0){$filedata=fread($handle, $length);$filecount+=$length;echo $filedata;}fclose($handle);}public static function DownLoadFile2($file){if ( file_exists ( $file )) { header ( 'Content-Description: File Transfer' ); header ( 'Content-Type: application/octet-stream' ); header ( 'Content-Disposition: attachment; filename=' . basename ( $file )); header ( 'Content-Transfer-Encoding: binary' ); header ( 'Expires: 0' ); header ( 'Cache-Control: must-revalidate' ); header ( 'Pragma: public' ); header ( 'Content-Length: ' . filesize ( $file )); ob_clean (); flush (); readfile ( $file ); exit;}}}
0 0
- PHP实现文件下载
- PHP实现文件下载
- PHP实现文件下载
- PHP实现文件下载
- php实现文件下载
- PHP实现文件下载
- php实现文件下载
- php实现文件下载
- php实现文件下载
- php 实现下载文件
- PHP实现文件下载
- php实现文件下载
- PHP实现文件安全下载
- 用PHP实现文件下载
- 用PHP实现文件下载
- PHP实现文件安全下载
- PHP实现文件安全下载
- 用PHP实现文件下载
- 【Kafka】Kafka在Linux下安装和测试
- MessagePack Java的使用
- 字符与数字转换
- 备忘
- Object中的wait,notify,notifyAll基本使用
- php 实现下载文件
- qt c++11 thread 执行错误
- C++ md5 小32位加密 (含源码下载)
- C#实现Discuz登录程序
- Android开发错误集锦
- android listview edittext 编辑 焦点
- 史上最全的maven pom.xml文件教程详解
- ajax异步上传文件,ajax提交表单中的文件到后台解析
- Shark与Spark SQL关系