lukebrandonfarrell's avatar

Storage Symbolic Link - Laravel Forge - Help!

  • I'm using Laravel Forge to host a website I built.
  • The website uses the 'store' function to store files into 'storage/app/public'.
  • On my local host I use a symbolic link 'php artisan storage:link' to give me the ability to access the image files using 'Storage::URL()'.

The images do not display, I believe this has something to do with the symbolic link.

http://46.101.35.173/talent/46

It works on Valet.dev / localhost.

Does anyone know how to solve this?

Thanks!

0 likes
14 replies
bashy's avatar

Firstly, if you store files in that folder, all you need to do is use the symlink and path to the file in your views. No need to even use Storage::url().

Have you got the symlink on the git repo you're pulling from?

1 like
bashy's avatar
bashy
Best Answer
Level 65

../storage/app/public should work. I have that setup for mine.

I think I set mine up locally like so;

cd public

ln -s storage ../storage/app/public
2 likes
lukebrandonfarrell's avatar

Turned out the storage path containing the photos was in .gitignore.

../storage/app/public worked.

Thanks for the help!

azimidev's avatar

No need to use your Unix power!

In root of your Laravel app:

php artisan storage:link 

This is provided by Laravel by default to create symbolic link

2 likes
bashy's avatar

@amirhazz Shame that if you have the symlink in git, it will be the wrong path. Using that command on each deploy is required or you can just use the unix command to add it properly, which will work each time.

2 likes
azimidev's avatar

@bashy Thanks very much for info. I Agree. Should run once in production again.

1 like
Deshola's avatar

Hi @bashy ,

Please I really ll need your input with a similar case to this three that I’m having.

I’m using Git with Envoyer to deploy my Laravel app. Image uploading work just fine on local machine. But each time I push to server, the “storage” folder in “public” folder disappears and I will have to run “php artisan storage:link” to get it back. This is tedious because each time I update my code and “git push” to remote, I need to run the command again.

Please, is there a parmenent fix to this? Thank you.

Deshola's avatar

@bashy , Thank you a lot. I figured it out and everything works perfectly.

Sadee's avatar

For me it has to be ln -s ../storage/app/public storage in the public/ directory

I am using Ubuntu 24.04.2 LTS

Please or to participate in this conversation.