标签:blog io os sp 文件 数据 div on log
function filedown($id, $type){
$ziliao = M("ziliao");
$data = $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();
}
标签:blog io os sp 文件 数据 div on log
原文地址:http://www.cnblogs.com/rnckty/p/4097439.html