首页 > 代码库 > PHP文件下载
PHP文件下载
function filedown($id, $type){ $ziliao = M("ziliao"); $data = http://www.mamicode.com/$ziliao->where("id=%d and type=%d",$id,$type)->find(); if(empty($data)){ $this->downerror("数据异常!"); } $filename = $data[‘name‘]; $path = $data[‘path‘]; $path = $_SERVER[‘DOCUMENT_ROOT‘] . $path; $path = iconv("UTF-8", "GB2312", $path); if(!is_file($path)){ $this->downerror("文件不存在!"); } $file = fopen($path,"r"); // 打开文件 // 输入文件标签 Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length: ".filesize($path)); Header("Content-Disposition: attachment; filename=" . iconv("UTF-8", "GB2312", $filename)); // 输出文件内容 echo fread($file,filesize($path)); fclose($file); exit();}
PHP文件下载
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。