我是laravel的新手。我通过编码json将多个图像作为数组插入数据库中
if($request->hasfile('image'))
{
foreach($request->file('image') as $image)
{
$name=$image->getClientOriginalName();
$image->move('images/formuploads/', $name);
$data[] = $name;
}
}
$upload= new classified_sales();
$upload->image=json_encode($data);
$upload->save();
}
我有以下代码用于插入数据,如何获取此图像数组以在引导模态中显示它们? 我应该如何在这里获取图片来源?
<button class="btn btn-primary saleflat-edit" id="flat_sale"
data-product="{{$classified_sales->product}}"
data-description="{{$classified_sales->description}}"
data-ownername="{{$classified_sales->ownername}}"
data-clf_id="{{$classified_sales->uid}}"
data-toggle="modal" data-target="#saleflat-edit">Edit</button>
答案 0 :(得分:0)
只需循环将数据追加到图像目录即可。
foreach($data as $image){ ?>
<img src="images/formuploads/<?php echo $image ?>">
<? }