DEV Community

srsagor
srsagor

Posted on

How to Image Validation in Laravel ?

So the file validation in file size to validate the file in laravel application. Now in case of string, it validates the length in characters. So now we need to a new validation option: image dimensions for image uploads. Now the validation rule is called dimensions.

public function solution(Request $request)
{
$request->validate([
'image' => 'required|image|mimes:jpg,png,jpeg,gif,svg|max:2048|dimensions:min_width=100,min_height=100,max_width=1000,max_height=1000',
]);

}

Details

Top comments (0)