|
@@ -293,21 +293,23 @@ class FileController |
|
@@ -293,21 +293,23 @@ class FileController |
|
293
|
if ($info === false) {
|
293
|
if ($info === false) {
|
|
294
|
$this->response('指定文件不存在!', Code::USER_ERROR);
|
294
|
$this->response('指定文件不存在!', Code::USER_ERROR);
|
|
295
|
}
|
295
|
}
|
|
|
|
296
|
+
|
|
296
|
if($info['is_cos'] == 1){
|
297
|
if($info['is_cos'] == 1){
|
|
297
|
$cos = new CosService();
|
298
|
$cos = new CosService();
|
|
298
|
- return $cos->downloadFile($info['path']);
|
299
|
+ $fileUrl = $cos->getImageUrl($info['path']);
|
|
299
|
}else{
|
300
|
}else{
|
|
300
|
$fileUrl = $this->config['root'].$info['path'];
|
301
|
$fileUrl = $this->config['root'].$info['path'];
|
|
301
|
if (!is_file($fileUrl)) {
|
302
|
if (!is_file($fileUrl)) {
|
|
302
|
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
|
303
|
$this->response('指定文件已被系统删除!', Code::USER_ERROR);
|
|
303
|
}
|
304
|
}
|
|
304
|
- $fileName = basename($info['path']); // 要保存的文件名
|
|
|
|
305
|
- // 设置响应头
|
|
|
|
306
|
- header('Content-Type: application/octet-stream');
|
|
|
|
307
|
- header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
|
|
|
308
|
- // 下载文件
|
|
|
|
309
|
- readfile($fileUrl);
|
|
|
|
310
|
}
|
305
|
}
|
|
|
|
306
|
+ $fileName = basename($info['path']); // 要保存的文件名
|
|
|
|
307
|
+ // 设置响应头
|
|
|
|
308
|
+ header('Content-Description: File Transfer');
|
|
|
|
309
|
+ header('Content-Type: application/octet-stream');
|
|
|
|
310
|
+ header('Content-Disposition: attachment; filename="' . $fileName . '"');
|
|
|
|
311
|
+ // 下载文件
|
|
|
|
312
|
+ readfile($fileUrl);
|
|
311
|
}
|
313
|
}
|
|
312
|
|
314
|
|
|
313
|
/**
|
315
|
/**
|