错误一:thinkphp5.1 致命错误:
Call to a member function validate() on null
注意表单添加:enctype="multipart/form-data"
注意二:上传图片要进行try,不然要报警告没有上传文件file
try{ $file = request()->file('img'); $info = $file->validate(['ext'=>'jpg,png,gif'])->move( '../public/uploads/'); if($info){ $data['img'] = str_replace("\\","/",$info->getSaveName()); }else{ $res = $file->getError(); return $this->sendError($res); } }catch (\Exception $e) { }