After pushing your code to your live server, the website doesn't show the public images you uploaded? This is a typical problem often asked on forums. These are the potential reasons/fixes.
Of course, it depends on how you load the image. The typical code is this:
<img src="{{ asset('images/logo.png') }}" />
Or, if you use a Spatie Media Library package:
<img src="{{ $user->getFirstMediaUrl('avatars') }}" />
First, what you need to do is to right-click that failed image and see its full URL. From that, you may realize your problem. Does that image contain an incorrect domain? Some subfolders missing in the path?
Then, check these three things:
- Check your
.env
file andAPP_URL
value: it should behttps://[yourwebsite.com]
- some people forget to change it from the defaultlocalhost
or provide incorrect URL with an extra folder/subdomain - If you store images in
storage/app/public
, check if you have runphp artisan storage:link
successfully (so, no errors happened) to create the symlink. - Check if your web-server root folder is successfully pointed to the
/public
folder of the Laravel project.
In my experience, these cover all potential cases of this problem.
I ran into this problem on Laravel Cloud. However the instructions from this article don't really seem to apply in this case. What would be the corresponding steps when using Laravel Cloud?
Sorry, we have not had enough experience with Cloud to help you here...
But from overall experience - I think you should use s3 to store the images and return it from there. Cloud (serverless) storage is often not persistent and you dont have much space there