正在显示
1 个修改的文件
包含
4 行增加
和
8 行删除
| @@ -48,7 +48,7 @@ class FileManageController extends BaseController | @@ -48,7 +48,7 @@ class FileManageController extends BaseController | ||
| 48 | @file_put_contents(storage_path('logs/lyh_error.log'), var_export($lists, true) . PHP_EOL, FILE_APPEND); | 48 | @file_put_contents(storage_path('logs/lyh_error.log'), var_export($lists, true) . PHP_EOL, FILE_APPEND); |
| 49 | if(!empty($lists) && !empty($lists)){ | 49 | if(!empty($lists) && !empty($lists)){ |
| 50 | foreach ($lists['list'] as $k => $v){ | 50 | foreach ($lists['list'] as $k => $v){ |
| 51 | - $v['download_url'] = url('b/file_manager_downLoad?hash='.$v['hash']); | 51 | + $v['download_url'] = url('b/file_manager_downLoad?hash='.$v['path']); |
| 52 | $lists[$k] = $v; | 52 | $lists[$k] = $v; |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| @@ -63,16 +63,12 @@ class FileManageController extends BaseController | @@ -63,16 +63,12 @@ class FileManageController extends BaseController | ||
| 63 | * @time :2023/12/28 17:18 | 63 | * @time :2023/12/28 17:18 |
| 64 | */ | 64 | */ |
| 65 | public function downLoad(){ | 65 | public function downLoad(){ |
| 66 | - $file_model = new FileManage(); | ||
| 67 | - $info = $file_model->read(['hash' => $this->param['hash']]); | ||
| 68 | - if ($info === false) { | ||
| 69 | - $this->response('指定文件不存在!', Code::USER_ERROR); | ||
| 70 | - } | ||
| 71 | - $fileUrl = 'https://file.globalso.com'.$info['path']; | 66 | + $username = basename($this->param['path']); |
| 67 | + $fileUrl = 'https://file.globalso.com'.$this->param['path']; | ||
| 72 | // 设置响应头 | 68 | // 设置响应头 |
| 73 | header('Content-Description: File Transfer'); | 69 | header('Content-Description: File Transfer'); |
| 74 | header('Content-Type: application/octet-stream'); | 70 | header('Content-Type: application/octet-stream'); |
| 75 | - header('Content-Disposition: attachment; filename="' . $info['name'] . '"'); | 71 | + header('Content-Disposition: attachment; filename="' . $username . '"'); |
| 76 | // 下载文件 | 72 | // 下载文件 |
| 77 | readfile($fileUrl); | 73 | readfile($fileUrl); |
| 78 | } | 74 | } |
-
请 注册 或 登录 后发表评论