注意:验证时check()的参数是$file = request()->file(),不要写成$file = request()->file(“image”);
$file = request()->file();
try {
validate(['image'=>'fileExt:jpg,png,gif,pdf'])->check($file);
$files = request()->file("image");
// 上传到本地服务器
$savename = \think\facade\Filesystem::disk('public')->putFile( 'topic', $files);
return success($savename);
} catch (\think\exception\ValidateException $e) {
// echo $e->getMessage();
return error($e->getMessage());
}