正在显示
2 个修改的文件
包含
36 行增加
和
0 行删除
@@ -48,6 +48,40 @@ class Upload extends Base { | @@ -48,6 +48,40 @@ class Upload extends Base { | ||
48 | 48 | ||
49 | } | 49 | } |
50 | 50 | ||
51 | + /** | ||
52 | + * 上传文件 | ||
53 | + * @return array | ||
54 | + * @throws \Lib\Err | ||
55 | + * @author:dc | ||
56 | + * @time 2025/1/16 10:26 | ||
57 | + */ | ||
58 | + public function file(){ | ||
59 | + $files = app()->file('files'); | ||
60 | + | ||
61 | + $result = []; | ||
62 | + | ||
63 | + if($files){ | ||
64 | + foreach ($files as $file){ | ||
65 | + $file->verify([ | ||
66 | + 'ext' => [], | ||
67 | + 'size' => 1024*50, | ||
68 | + 'mine' => [] | ||
69 | + ]); | ||
70 | + | ||
71 | + if($file->move()){ | ||
72 | + $result[] = [ | ||
73 | + 'name' => $file->name, | ||
74 | + 'saveName' => $file->saveName, | ||
75 | + 'saveUrl' => APP_HOST.$file->saveName | ||
76 | + ]; | ||
77 | + } | ||
78 | + | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + return $result; | ||
83 | + } | ||
84 | + | ||
51 | 85 | ||
52 | 86 | ||
53 | 87 |
@@ -66,6 +66,8 @@ return [ | @@ -66,6 +66,8 @@ return [ | ||
66 | 66 | ||
67 | // 上传图片 | 67 | // 上传图片 |
68 | 'upload/image' => [\Controller\Upload::class, 'image'], | 68 | 'upload/image' => [\Controller\Upload::class, 'image'], |
69 | + // 上传文件 | ||
70 | + 'upload/file' => [\Controller\Upload::class, 'file'], | ||
69 | 71 | ||
70 | // 解析 订阅url参数 数据 | 72 | // 解析 订阅url参数 数据 |
71 | 'desubscribe' => [\Controller\Home::class, 'desubscribe'] | 73 | 'desubscribe' => [\Controller\Home::class, 'desubscribe'] |
-
请 注册 或 登录 后发表评论