Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - How get images from /storage

I'm having problems to get images from storage. So i upload files and images to storage. When the file is image i upload to storage/images/ and the file goes there right.

In database it saves this: /images/image01.png .

In blade view i try to do this but doesn't work:

<img src="<?php echo asset("storage/". $images[0]->image)?>" />

In html it shows like this:

<img src="http://localhost:8000/storage/images/image01.png">

How can i do that?

Thank you

like image 823
user3242861 Avatar asked Sep 13 '25 16:09

user3242861


1 Answers

Laravel provides some function to store file on storage path.

You should use that:

php artisan storage:link

You can see storage/app/public/ will be created.

You shoud save all image in this folder.

Note: if you want to make new folder in storage/app/public/ you should set 755 permission for this folder

Example: mkdir('storage/app/public/avatar', 0755, true)

Updated:Load in blade like that if you stored in storage/app/public/avatar

 <img src="{{asset("storage/avatar/img.jpg")}}" alt="">
like image 85
Vu Hoang Duc Avatar answered Sep 16 '25 07:09

Vu Hoang Duc