Home / Snippets / Laravel Image validation Rule
Laravel Image validation Rule cover

Laravel Image validation Rule

208

3 years ago

0 comments

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'
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

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

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this