tp6文件上传功能报错Argument 1 passed to think\Validate::check() must be of the type array ....

tp6文件上传功能报错Argument 1 passed to think\Validate::check() must be of the type array ...._第1张图片
注意:验证时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());
        }

你可能感兴趣的:(php,php)