Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Image Validation Rule Example

Laravel

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
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
2
0
Would love your thoughts, please comment.x
()
x