max:size 方法不存在
max:size method doesn't exist
用户需要能够限制上传大小,我设置了该变量,现在验证给我带来了问题。我在验证中有这个
$var = Model::where('id','=','1')->first();
$up=$var->size;
验证
$this->validate($request, [
'file' => "'max:".$up."'",
]);
上面写着
Method [validate'max] does not exist.
假设 $up = 10;
那么验证字符串必须是 'max:10'
。
删除最大值周围的单引号将解决问题。
因此您必须更改您的代码:
'file' => "'max:".$up."'"
至
'file' => "max:".$up
用户需要能够限制上传大小,我设置了该变量,现在验证给我带来了问题。我在验证中有这个
$var = Model::where('id','=','1')->first();
$up=$var->size;
验证
$this->validate($request, [
'file' => "'max:".$up."'",
]);
上面写着
Method [validate'max] does not exist.
假设 $up = 10;
那么验证字符串必须是 'max:10'
。
删除最大值周围的单引号将解决问题。
因此您必须更改您的代码:
'file' => "'max:".$up."'"
至
'file' => "max:".$up