正在显示
1 个修改的文件
包含
4 行增加
和
12 行删除
| @@ -225,22 +225,14 @@ class FileController | @@ -225,22 +225,14 @@ class FileController | ||
| 225 | */ | 225 | */ |
| 226 | public function downLoad(){ | 226 | public function downLoad(){ |
| 227 | $file_model = new File(); | 227 | $file_model = new File(); |
| 228 | - var_dump($this->param['path']); | 228 | + $info = $file_model->read(['path' => str_replace_url($this->param['path'])]); |
| 229 | + var_dump($info); | ||
| 229 | die(); | 230 | die(); |
| 230 | - $info = $file_model->read(['path' => str_replace_url($this->param['path'])]); | ||
| 231 | if ($info === false) { | 231 | if ($info === false) { |
| 232 | $this->response('指定文件不存在!', Code::USER_ERROR); | 232 | $this->response('指定文件不存在!', Code::USER_ERROR); |
| 233 | } | 233 | } |
| 234 | - if($info['is_cos'] == 1){ | ||
| 235 | - $cos = new CosService(); | ||
| 236 | - $fileUrl = $cos->getImageUrl($info['path']); | ||
| 237 | - }else{ | ||
| 238 | - $fileUrl = $this->config['root'].$info['path']; | ||
| 239 | - if (!is_file($fileUrl)) { | ||
| 240 | - $this->response('指定文件已被系统删除!', Code::USER_ERROR); | ||
| 241 | - } | ||
| 242 | - } | ||
| 243 | - $fileName = basename($info['path']); // 要保存的文件名 | 234 | + $url = getFileUrl($info['path'],$info['is_cos']); |
| 235 | + $fileName = basename($url); // 要保存的文件名 | ||
| 244 | // 设置响应头 | 236 | // 设置响应头 |
| 245 | header('Content-Description: File Transfer'); | 237 | header('Content-Description: File Transfer'); |
| 246 | header('Content-Type: application/octet-stream'); | 238 | header('Content-Type: application/octet-stream'); |
-
请 注册 或 登录 后发表评论