image size validation in laravel code example
Example 1: laravel validate max file size
$validator = Validator::make($request->all(), [
'file' => 'max:500000',
]);
Example 2: image dimension when uploading in laravel validation
$this->validate($request, [ 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048|dimensions:width=500,height=500',]);
Example 3: laravel image ratio validation
public function postImage(Request $request)
{
$this->validate($request, [
'avatar' => 'dimensions:min_width=250,min_height=500'
]);
$this->validate($request, [
'avatar' => 'dimensions:min_width=500,max_width=1500'
]);
$this->validate($request, [
'avatar' => 'dimensions:width=100,height=100'
]);
$this->validate($request, [
'avatar' => 'dimensions:ratio=3/2'
]);
}