Posts Learn Components Snippets Categories Tags Tools new About
/

Laravel Image validation Rule

Learn how to define laravel image validation rule

Created on Aug 02, 2021

39 views

To validate the image file in Laravel you can specify the rule inside the validator "method()". Inside the validate method you can define the validator necessary for the image like below.
<?php

Route::post('/image-upload', function (Request $request) {
    $request->validate([
        'image-upload' => 'required|image|mimes:jpeg,png,jpg|max:1024',
    ]);
});

To get the dimension you can define it as follows (maximum width 1080px and height 600px).
'image-upload' => 'dimensions:max_width=1080,max_height=600'

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Laravel Image validation Rule

)