1
Laravel問題: 如何在數據庫中存儲和顯示圖像。
可以幫我解決嗎?
Laravel保存並顯示數據庫中的圖像
這裏是我的代碼:
店內碼:
public function store(FormRequest $request)
{
$slug = uniqid();
$item = new Item(array(
'title' => $request->get('title'),
'image' => $request->get('image'),
'content' => $request->get('content'),
));
$item->save();
}
顯示代碼:
@foreach($items as $item)
<tr>
<td>{!! $item->id !!} </td>
<td>{!! $item->title !!}</td>
<td><img src="{{ asset($item->image) }}" /></td>
</tr>
@endforeach
也許忘了部分代碼,你在這裏做的只是添加項目到數據庫,但你不會在任何地方檢索它們。 – Andrew