Answers for "laravel image upload helper"

PHP
0

upload image in laravel

<?php
  
namespace AppHttpControllers;
  
use IlluminateHttpRequest;
  
class ImageUploadController extends Controller
{
     /**
     * Display a listing of the resource.
     *
     * @return IlluminateHttpResponse
     */
    public function imageUpload()
    {
        return view('imageUpload');
    }
    
    /**
     * Display a listing of the resource.
     *
     * @return IlluminateHttpResponse
     */
    public function imageUploadPost(Request $request)
    {
        $request->validate([
            'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
        ]);
    
        $imageName = time().'.'.$request->image->extension();  
     
        $request->image->move(public_path('images'), $imageName);
  
        /* Store $imageName name in DATABASE from HERE */
    
        return back()
            ->with('success','You have successfully upload image.')
            ->with('image',$imageName); 
    }
}
Posted by: Guest on January-10-2022
0

laravel upload image

If the upload isnt working try this in you php.ini
  
upload_max_filesize = 20M
post_max_size = 20M
Posted by: Guest on December-28-2021

Browse Popular Code Answers by Language