davidkihara
davidkihara

Reputation: 533

How do I display and image from database to laravel blade?

I have followed the correctly marked answer in this question to save images in my app. I am having trouble displaying the images to blade file. I am using <img src="{{asset('/ProfileImages'.$p->profile_image)}}" alt="..."> ProfileImages is the storage folder with structure storage/app/ProfileImages. How do I display the images as the above line doesnot display?

Upvotes: 0

Views: 1113

Answers (3)

VIKAS KATARIYA
VIKAS KATARIYA

Reputation: 6005

Laravel storage filesystem is so unique. When you doing any upload it will upload in the storage/app/public directory. To make it accessible in public directory, things need to do is create symlink by run command:

php artisan storage:link

Or

<img src="{{ Storage::url($p->profile_image) }} " alt=""/>

StorageDocumentation

Upvotes: 1

Jovan Djordjevic
Jovan Djordjevic

Reputation: 91

By default when using {{asset()}} this will look inside your Public directory you should either consider storing photos inside your Public directory

Or take a look at the documentation about Laravel File System, here they explain how you can use storage directory and link it with your public directory Laravel File System

Aslo you can use {{Storage::url()}} instead

Upvotes: 1

Kamlesh Paul
Kamlesh Paul

Reputation: 12401

use Storage::url()

<img src="{{ Storage::url($p->profile_image) }}" alt="...">

ref link https://laravel.com/docs/8.x/filesystem#file-urls

Upvotes: 1

Related Questions