laravel image validation
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
laravel image validation
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
Upload image laravel 6
<?php
namespace App\Http\Controllers\simple_image_upload;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Validator,Redirect,Response,File;
use App\Photo;
class ImageUploadController extends Controller
{
//
public function index()
{
return view('simple_image_upload.index');
}
public function store(Request $request)
{
request()->validate([
'profile_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
if ($files = $request->file('profile_image')) {
// Define upload path
$destinationPath = public_path('/profile_images/'); // upload path
// Upload Orginal Image
$profileImage = date('YmdHis') . "." . $files->getClientOriginalExtension();
$files->move($destinationPath, $profileImage);
$insert['image'] = "$profileImage";
// Save In Database
$imagemodel= new Photo();
$imagemodel->photo_name="$profileImage";
$imagemodel->save();
}
return back()->with('success', 'Image Upload successfully');
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us