I'm trying to store multiple images to the database but it only stores one image. I don't see any errors. I have tried this but it stores images in public folder, I want the images to be stored in database. How can I fix this? any help would be appreciated.
Controller
if($request->hasFile('files')){
$files = $request->file('files');
foreach ($files as $file) {
$filename = $file->getClientOriginalName();
$images = $file->store('public/photos');
}
}
ProductsPhoto::create([
'product_id' => $product->id,
'filename' => $images
]);
Blade
<input type="file" name="files[]">
multipleto input, see if that changes things. Try dodd($files);after you set the variable to ese if it actually has multiple items.$images = $file->store('public/photos');this is actually storing the file on the disk. What you are storing in the database is only the path to the file.