thinkphp控制器实现隐藏文件路径下载
/**
* 下载模型栏目控制器
*/
public function download(){
//模板显示文章
$User = M("Config"); // 实例化User对象
// 把查询条件传入查询方法
$arr=$User->select();
$address=$arr[0]['config_address'];
// dump($arr);
// exit;
$file_name = $address;//文件名字
$file_dir = "http://www.tuzicms.com/Uploads/Goods/Tuzicms/";//文件路劲
$file = @ fopen($file_dir . $file_name,"r");
if (!$file) {
echo "文件找不到";
} else {
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=" . $file_name);
while (!feof ($file)) {
echo fread($file,50000);
}
fclose ($file);
}
}