OunknownO OunknownO - 2 months ago 5x
PHP Question

max:size method doesn't exist

User needs to have ability to limit upload size and I set that variable and now validation is giving me problems. I have this in my validation

$var = Model::where('id','=','1')->first();


$this->validate($request, [
'file' => "'max:".$up."'",

and it says

Method [validate'max] does not exist.


Assume $up = 10; then validation string must be 'max:10'. Removing single quotes around the max will solve the problem.

So you have to change yout code from:

'file' => "'max:".$up."'" to

'file' => "max:".$up