Home > Net >  How to retrieve multiple image from database which is seperated by , in laravel 8
How to retrieve multiple image from database which is seperated by , in laravel 8

Time:10-16

I am new to laravel and I am working on a project where I saved multiple image in a single column where image is separated with a column but I am unable to fetch images my data insert code is below

        $AllVehicleImage="";
        if($request->hasFile("VecImages"))
        {
            $files=$request->file("VecImages");
            foreach($files as $file)
            {
                $imageNameV=time().'_'.$file->getClientOriginalName();
                $request['VecImages']=$imageNameV;
                $file->move(\public_path("/assets/Resources/Images/DynamicImage/Products/") , $imageNameV);
                $AllVehicleImage.=$imageNameV.",";
            }
        }
        $VehicleSalsePost->image = $AllVehicleImage;
        $VehicleSalsePost->save();

This is how I am sending image to folder and saving it but I am unable to fetch image in my blade. this blade file is for admin control side file my blade file code looks like

@extends('Admin.Master.Layout.Sidebar')
@section('Content')
    
                                  <input type="file" id="RetrievedImage" class="form-control" id="exampleFormControlInput1" value="{{ $item->image }}" required>
                              
        @endforeach
      

@endsection

The image file are to be fetched in dropzone

As I am new some explained code will be really appreciated.

Thank you

CodePudding user response:

you can use explode function to separate images

$images = explode(",",$value_column _image );

https://www.php.net/manual/en/function.explode.php?

CodePudding user response:

You this code in you blade file:

@extends('Admin.Master.Layout.Sidebar')
@section('Content')
    @foreach(explode(", ", $AllVehicleImage) as $item)
        <input type="text" id="RetrievedImage" class="form-control" id="exampleFormControlInput1" value="{{ $item }}" required>                          
    @endforeach
@endsection
  • Related