Search code examples
phplaravelfile-uploadlaravel-filesystem

Laravel: Make Images Stored in Storage Folder Publicly Accessible


I am storing images in the Laravel storage folder. They are stored in the following format.

C:\xampp\htdocs\personal_projects\Active\diary_app\storage\app\images\C4CA4238\C81E728D9D4C2F63.png

I want to make these images publicly accessible for the user that uploaded them. I followed the instructions here: https://laravel.com/docs/5.5/filesystem

"you should create a symbolic link from public/storage to" storage/app/public

So I ran php artisan storage:link and have the "symbolic link" showing up in my public directory:

enter image description here

I am trying to display my images using the following url:

http://localhost/personal_projects/Active/diary_app/public/storage/app/images/C4CA4238/C81E728D9D4C2F63.png"

But I get 'image not found'. How do I make images stored in storage publicly accessible?


Solution

  • Images stored in the storage/app/public directory are publicly accessible via http://your.domain/storage when the php artisan storage:link command has been run.

    I.e, storage_path('app/public') . '/path/to/image.jpg' would be accessed like so: http://your.domain/storage/path/to/image.jpg.