Return to site
· Web Development,Web,Laravel,Image upload
broken image

Laravel provides you built-in functions for uploading any type of file, Here is the code for you to upload an image in Laravel. This code is written in Laravel 5.4 version.public function fileUpload(Request $request) {

        'input_img' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',

    ]);

 

    if ($request->hasFile('input_img')) {

        $image = $request->file('input_img');

        $name = time().'.'.$image->getClientOriginalExtension();

        $destinationPath = public_path('/images');

        $image->move($destinationPath, $name);

        $this->save();

 

        return back()->with('success','Image Upload successfully');

    }

}

 Use the controller fileuse Illuminate\Support\Facades\Input;Read more