|
...
|
...
|
@@ -293,22 +293,24 @@ class FileController |
|
|
|
if ($info === false) {
|
|
|
|
$this->response('指定文件不存在!', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($info['is_cos'] == 1){
|
|
|
|
$cos = new CosService();
|
|
|
|
return $cos->downloadFile($info['path']);
|
|
|
|
$fileUrl = $cos->getImageUrl($info['path']);
|
|
|
|
}else{
|
|
|
|
$fileUrl = $this->config['root'].$info['path'];
|
|
|
|
if (!is_file($fileUrl)) {
|
|
|
|
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fileName = basename($info['path']); // 要保存的文件名
|
|
|
|
// 设置响应头
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
header('Content-Type: application/octet-stream');
|
|
|
|
header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
|
|
|
// 下载文件
|
|
|
|
readfile($fileUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存路径
|
...
|
...
|
|