Image Validation Rule Example

Posted by

You’ll see an illustration of Laravel 9 image validation rules in this article. I gave a brief explanation on laravel 9 image validation. Laravel 9 image validation size will be used. This post covers Laravel 9 image validation mimes in detail. Check out the example laravel 9 image width and height below.

Laravel 9 provides list of default image validation rules to prevent user.

  • image
  • mimes
  • dimensions
  • max

The file types “jpg,png,jpeg,gif,svg” and “max” can be defined using the aforementioned validation criteria, and the file size limit can be set using max. You can limit file height and width using dimensions. Let’s look at the following straightforward sample code.

Example:

          $this->validate($request, [
            'image' => ['required',
                        'image',
                        'mimes:jpg,png,jpeg,gif,svg',
                        'dimensions:min_width=100,min_height=100,max_width=1000,max_height=1000',
                        'max:2048'],
        ]);  
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x