Reputation: 5492
I am trying to access an image in the url which is stored in the /storage folder.
Image Stored Path:
Project/storage/app/public/default.png
According to Laravel 5.5 docs, your publicly accessible files should be put in directory
storage/app/public
So I did the same, but when I try to access the image as:
http://localhost:8000/storage/default.png
then it doesn't work.
I tried the following command:
php artisan storage:link
but it throws an error:
The "public/storage" directory already exists.
Upvotes: 1
Views: 18350
Reputation: 23
Try Deleting the storage Folder in the Public Directory and then Run This Command "php artisan storage:link" then try it.
Upvotes: 1
Reputation: 164
The best way to do it is to first remove the symlink by running a code that will remove storage from the public folder first like so:
$ rm public/storage
then rerun the symlink code again
$ php artisan storage:link
You will see that afterwards the public/storage folder will reappear and will be updated
Upvotes: 10
Reputation: 331
Sep 2019
What's working for me:
If you run into any errors:
Upvotes: 0
Reputation: 554
As for 2019, if any of you got this error:
"The "public/storage" directory already exists."
Then go to your public folder and delete the "storage" file.
Once you do it, run again the "php artisan storage:link" and it will work now
Upvotes: 16
Reputation: 57
Try deleting storage folder inside app/public/storage than run the command(php artisan storage:link
) again and than you can access file using this path
http://localhost:8000/storage/<folder_name_if_folder_exists>/<file_name>.<extension>
Upvotes: 3
Reputation: 5042
First use php artisan storage:link
Then you can access all public path using /* like:
http://localhost:8000/default.png
Above command allow you to get images directly from public path!
Hope this helps you!
Upvotes: 1
Reputation: 2333
You cannot access files inside storage folder directly as you tried. First you have to create a symbolic link of your storage "public" folder to your real "public" folder.
php artisan storage:link
Try again after the command.
NOTE: If you are using windows open command line (cmd, git bash...) as admin to avoid errors.
Upvotes: 2