Flex's avatar
Level 4

how to upload maximam 5 images one by one and save in one table column?

Hi, I need in My form attach maximum 1-5 images without refresh one by one and save in one column all images I have following ImageGalleryController.php. but it is upload one image per one saving and save one images in the column. I need modify this upload maximam 5 images and saving images in one column.

ImageGalleryController.php

<?php


namespace App\Http\Controllers;


use Illuminate\Http\Request;

use App\ImageGallery;


class ImageGalleryController extends Controller

{


    /**

     * Listing Of images gallery

     *

     * @return \Illuminate\Http\Response

     */

    public function index()

    {

        $images = ImageGallery::get();

        return view('image-gallery',compact('images'));

    }


    /**

     * Upload image function

     *

     * @return \Illuminate\Http\Response

     */

    public function upload(Request $request)

    {

        $this->validate($request, [

            'title' => 'required',

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

        ]);


        $input['image'] = time().'.'.$request->image->getClientOriginalExtension();

        $request->image->move(public_path('images'), $input['image']);


        $input['title'] = $request->title;

        ImageGallery::create($input);


        return back()

            ->with('success','Image Uploaded successfully.');

    }


    /**

     * Remove Image function

     *

     * @return \Illuminate\Http\Response

     */

    public function destroy($id)

    {

        ImageGallery::find($id)->delete();

        return back()

            ->with('success','Image removed successfully.');    

    }

}

0 likes
1 reply

Please or to participate in this conversation.