DEV Community

Cover image for Laravel Validation Dimensions Example Tutorial
Sonagrabhavesh
Sonagrabhavesh

Posted on

Laravel Validation Dimensions Example Tutorial

Hi Dev,

In this tutorial, i will explicated to the Laravel Validation Dimensions Example in your laravel project.Laravel provide incipient image dimensions validation option for image upload and you are able to utilize this dimensions validation in laravel 6, laravel 7 and laravel 8 project.Laravel Validation Dimensions Example is so facile to utilize.so you can just follow my step by step and learn Laravel Validation Dimensions Example.

So, let's get start to the example and follow to the my all step.

Dimensions Rules:

1)width    
2)height    
3)min_width    
4)min_height    
5)max_width    
6)max_height    
7)ratio    

In this Dimensions option through we can set fine-tune width and height, if invalid width and height of image then it will return error. Same way we can set validation min and max height width on your validation.

Few days ago i posted image upload with validation post in Laravel 5.3, you can optically discern here : Laravel 5.3 Image Upload with Validation example..

In this post i used simple validation with mime type and max size like as bellow :

Step 1: Create Route
Last step to create a route in web.php file and use this code.

Route :routes/web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\UserController;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('dimention/form', [UserController::class, 'dimentionForm'])->name('dimention.form');
Route::post('dimention/store', [UserController::class, 'dimentionStore'])->name('dimention.store');

Step 2: Create a UserController Controller

if you want to see full example follow this link..

https://codingtracker.blogspot.com/2021/05/laravel-validation-dimensions-example.html

Top comments (1)

Collapse
 
sloan profile image
Sloan the DEV Moderator

Hi there, we encourage authors to share their entire posts here on DEV, rather than mostly pointing to an external link. Doing so helps ensure that readers don’t have to jump around to too many different pages, and it helps focus the conversation right here in the comments section.

If you choose to do so, you also have the option to add a canonical URL directly to your post.