I am trying to display a row from my database by id, the data displayed successfully but the image doesn't show (showing a broken link icon).
Here is the index.blade.php where the href to the row:
<a href="singlepost/{{$products->id}}">
<img src="storage/{{$templates->image_path2}}">
The route:
Route::get('/singlepost/{id}', 'App\http\controllers\TemplatesController@getPostById')->name('single.post');
The function getPostById
public function getPostById($id){
$products = DB::table('templates')->where('id', $id)->first();
return view('singlepost', compact('products'));
}
The singlepage.blade.php
<div class="row">
<div class="col-lg-4">
<img src="storage/{{$products->image_path}}">
</div>
<div class="col-lg-7">
<h2>{{$products->name}}</h2>
<p>{{$products->description}}</p>
</div>
</div>
copy image addressand paste it here pleasesrc="storage..., add a slash beforestorage, or try with the asset helper<img src="{{ asset('storage'.$products->image_path) }}">.php artisan storage:linkcommand? Is the file stored inyour-project/storage/app/publicdirectory?