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
.envfile andAPP_URLvalue: it should behttps://[yourwebsite.com]- some people forget to change it from the defaultlocalhostor provide incorrect URL with an extra folder/subdomain - If you store images in
storage/app/public, check if you have runphp artisan storage:linksuccessfully (so, no errors happened) to create the symlink. - Check if your web-server root folder is successfully pointed to the
/publicfolder of the Laravel project.
In my experience, these cover all potential cases of this problem.
No comments yet…