User1980's avatar

Laravel validator Mimes SIZES not working

Hello,

When I upload a file with vue and try to check it with the Laravel validator using:

            $validator = Validator::make($request->all(), [
                'file1' => 'nullable|mimes:jpeg,png,jpg|max:500|dimensions:max_width=400,max_height=400',
            ]);

            if ($validator->fails()) {
                return response()->json(['errors' => $validator->errors()], 422);
            }

I tried to upload a file as big as 2.5 meg and also with dimensions of 600 x 400 px, they all pass through.

Any idea why please?

Thanks

0 likes
2 replies
manojo123's avatar
Level 14

Are you receiving the file? can you confirm that you added the enctype to the form

<form action="/action" method="post" enctype="multipart/form-data">
1 like
User1980's avatar

@manojo123 My mistake :-) the image was sent to the wrong controller and I was modifying the wrong validator... :-)

Please or to participate in this conversation.