Problem in multiple image upload in laravel 8

  file-upload, laravel, php

I got an error in laravel 8, while uploading multiple images.

Argument 1 passed to IlluminateDatabaseGrammar::parameterize()

must be of the type array, string given, called in
C:xampphtdocslaravel_cmsvendorlaravelframeworksrcIlluminateDatabaseQueryGrammarsGrammar.php
on line 886

Here is my code in controller:

 $gallery =  new GalleryImage; 
 foreach( $req->file('image_name') as $image)
   {
     $upload_image_name = time().'_'.$image->getClientOriginalName();
     $image->move('uploads', $upload_image_name);    
     $name[] = $upload_image_name;         
   } 
    $gallery->image_name = $name;        
    $gallery->save();         
    return redirect()->back()->with('status','Image Uploaded Successfully.');

Code in blade:

<input name="image_name[]" id="exampleFile" type="file" accept="image/*" multiple>

If I return $req->file('image_name') file is showing empty

Source: Laravel

Leave a Reply