That is not a good practice to add tow file name in a single column. beacause while retrieving those images it will get complicated. instead you can add another column to your table and specify that in to nullable(). and then store the second image or file into your table.
Jan 24, 2018
9
Level 4
How to Store Multiple images filename in one column Using Laravel
Hi,
I have tried with upload multiple images to the database it gets uploaded to the images folder successfully in the database it shows only one images folder name is this possible in the laravel to store two images filename in one column
in the uploadcontroller.php file
$prod = new \App\Product;
$prod->name = Input::get('name');
if(! is_null(request('images')))
{
$photos=request()->file('images');
$uploadcount = 0;
foreach ($photos as $photo)
{
$destinationPath = 'images';
$filename = $photo->getClientOriginalName();
$photo->move($destinationPath,$filename);
$uploadcount ++;
$photo->getClientOriginalExtension();
$prod->mime = $photo->getClientMimeType();
$prod->filename = $filename;
}
}
$prod->save();
Thanks,
Level 4
you should create a other table that can be named images and make a foreign key between product table and images table,you are using very old method for storing your images link :~) you should use one to many relation between your product and images table! you can find very helpful docs in laravel own site! if you had and problems I can send you sample code!
3 likes
Please or to participate in this conversation.