Reputation: 107
I save images in my database(the name of the image) and the images are saved in my public/images directory(it works). I have one too many relationships and I put a dd()
to see if I get the data correctly from the database and yes, It is correct. Now I want to have in my view those images but I don't know how to write the correct path for this. I try something like this :
@foreach($result as $res)
@foreach($res->images as $file)//in images i have the pics
<tr>
<td><img src="{{ asset('public/images/' . $file->file_name)}}" /></td>
</tr>
@endforeach
@endforeach``
But $file->file_name
is not treated as a variable in Visual studio code. How can I obtain the correct path to display my pics correctly? thank you
Upvotes: 0
Views: 50
Reputation: 12391
remove public
from asset()
function, this helper point to public
dir
<td><img src="{{ asset('images/' . $file->file_name)}}" /></td>
ref link https://laravel.com/docs/8.x/helpers#method-asset
Upvotes: 1