增加上传文件格式验证,感谢群友冷风

This commit is contained in:
巴掌 committed 2022-07-13 16:57:25 +08:00
1 parent 3213abd282
commit 24b9589416
3 files changed
+41 -1

No files matched your search

+10 -1
View File
@@ -98,8 +98,17 @@ class File extends BaseController
// 获取表单上传文件
$file = request()->file('file');
$data = $this->saveFileInfo($file, $list, true);
$list['file'] = $file;
// 验证表单数据
$validate = new \app\tools\validate\File;
$result = $validate->check($list);
$msg = $validate->getError();
if(!$result){
return json(['msg' => $msg, 'val' => 0]);
}else {
$data = $this->saveFileInfo($file, $list, true);
}
return json($data);
}
}