Laravel image validation example
devcse
Posted on July 21, 2021
Hi artisan, today I will show you how to validate images in your laravel project easily.
Solution
$request->validate([
'file' => 'image'
]);
Route : routes/web.php
Route::get('form-create','FromController@index');
Route::post('form-store','FromController@store')->name('form.store');
Controller : app/Http/Controllers/ImgController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Blade;
use App\Models\User;
use App\Models\Post;
class FromController extends Controller
{
public function create()
{
return view('form');
}
public function store(Request $request)
{
$request->validate([
'file' => 'image'
]);
}
}
GET FULL CODE: Laravel image validation example
💖 💪 🙅 🚩
devcse
Posted on July 21, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.