在Laravel中使用SQL查询数组作为html图像源

I'm doing a laravel project. I save user's profile pictures in a folder on my server, and the path to that photo in the db table. I use a sql query to form an array with all the information, and then am able to access the information in HTML like this: {{profile.FirstName}} etc. I am trying to display the user's profile picture.

I have tried doing <img src="profile_pictures/{{profile.username}}" and also src={{profile.profilePic}} where the profilePic cell has the path to the photo, and neither work. Should I try saving the path in the table with quotes around it and then try the second option? Or is there a proper way to do this?

use asset()

asset() Generate a URL for an asset using the current scheme of the request (HTTP or HTTPS). See More

Consider User Model have profile_picture attribute

Where $user->profile_picture wil give you image path stored in path

For example:

echo $thatUser->profile_picture;
//Will show this path "profilepictures/thatUser/image.jpg
//Real path: project/public/profilepictures/thatUser/image.jpg

To show that image in view use asset()

<img src={{ asset($thatUser->profile_picture) }}" alt="that user image"></img>

If you right click and view page source is it showing the correct path? If you're using Angular partials stored in the public folder of the Laravel project, make sure that path from the partials directory to profile_pictures directory is correct. If your using views in the resources folder same thing goes.