我尝试为我的产品上传多个图像,并将该图像的名称作为数组存储在数据库中。我的代码是这样工作的 -
$images = $request->file('images');
if (isset($images)) {
foreach($images as $image){
$imagename = $slug.'-'.$currentDate.'-'.uniqid().'.'.$image->getClientOriginalExtension();
if (!file_exists('uploads/product/images')) {
mkdir('uploads/product/images', 0777, true);
}
$image->move('uploads/product/images', $imagename);
$data[] = $imagename;
}
}else{
$data[] = 'default.png';
}
$product = new Product();
$product->images = json_encode($data);
以及存储在字段内的数据,images例如-
["jeans-2020-08-13-5f352f18b30a4.jpg","jeans-2020-08-13-5f352f18b36a0.jpg","jeans-2020-08-13-5f352f18b3a2c.jpg"]
**问题是我如何分离这个图像名称以在 Laravel Blade 中显示图像?**
或者建议我,如果有其他方法可以在 laravel-6 中上传多个图像或多个值
慕田峪9158850