laravel upload image

75

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
  
class ImageUploadController extends Controller
{
     /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function imageUpload()
    {
        return view('imageUpload');
    }
    
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    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); 
    }
}
$fileName = $file->storePublicly('images/media', [
            'disk' => 's3'
        ]);
  $image= $request->image;
         $imageName=time().'.'.$image->getClientOriginalExtension();
         $request->image->move('imagefolder', $imageName);
         $data->image=$imageName;
  $image= $request->image;
         $imageName=time().'.'.$image->getClientOriginalExtension();
         $request->image->move('chefsimage', $imageName);
         $data->image=$imageName;

Comments

Submit
0 Comments