This is how my blade looks like:
<div class="form-group row">
<label for="gallery-image" class="col-sm-3 text-left control-label col-form-label">Photo</label>
<div class="col-md-9">
{{-- <input type="file" name="images[]" multiple> --}}
<input type="file" class="form-control form-control-file"
id="gallery-image" value="{{ old('gallery-image') }}" required name="gallery-image[]" multiple/>
<span class="below-image-upload-msg">Advised image dimensions: 1920 x 450 pixels. File size should be less than 2Mb per image.</span>
</div>
@error('image')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
And this is how the store function in the controller looks like:
public function store(Request $request){
$validation = Validator::make($request->all(), array(
'gallery-id' => 'required|integer|min:0',
'gallery-image' => 'required|image|nullable|mimes:jpeg,png,jpg,gif|max:2048',
));
$fileNameToStore="no-image.jpg";
if(request('gallery-image'))
{
$iCount=0;
foreach($request->file('gallery-image') as $thisImage){
$fileNameWithExtension = $thisImage->getClientOriginalName();
$memberName = Auth::user()->MemberProfile->member_tourist_office_name;
$extension=$thisImage->getClientOriginalExtension();
$fileNameToStore = $fileName.'_'.time().$iCount.'.'.$extension;
$path= $thisImage->storeAs('public/images/members/gallery-images',$fileNameToStore);
$isEnabled = "0";
$galleryImage = new GalleryImage();
$galleryImage->gallery_id = request('gallery-id');
$galleryImage->gallery_image_caption = " ";
$galleryImage->gallery_image = $fileNameToStore;
$galleryImage->isEnabled = $isEnabled;
$galleryImage->save();
$iCount++;
}
return redirect('/galleryimage/create')->with('success', 'Image(s) successfully added to gallery!');
}
}