I am trying to see image in this link http://127.0.0.1:8000/images/files/Safety/1738837934.png
in my Laravel application. But I am getting 404 error while I try to see the image. I placed my images inside /public/storage/files/Safety/
folder.
I can see some images but some images are not visible.
I am trying to see image in this link http://127.0.0.1:8000/images/files/Safety/1738837934.png
in my Laravel application. But I am getting 404 error while I try to see the image. I placed my images inside /public/storage/files/Safety/
folder.
I can see some images but some images are not visible.
Share Improve this question edited Feb 6 at 11:22 abu abu asked Feb 6 at 10:49 abu abuabu abu 7,02223 gold badges82 silver badges155 bronze badges 2 |2 Answers
Reset to default 4You've put the file in one place and are trying to access it in another place.
The public
directory is web root for your Laravel application, so if you've put the file in /public/storage/files/Safety/1738837934.png
, then it would be accessible at http://127.0.0.1:8000/storage/files/Safety/1738837934.png
.
If your images are stored in public/storage/files/Safety/
and some are not loading, follow these steps:
1. Check if the File Exists
Run:
ls -l public/storage/files/Safety/
Ensure the image exists.
2. Use the Correct URL
Try:
http://127.0.0.1:8000/storage/files/Safety/1738837934.png
Update your Blade template:
<img src="{{ asset('storage/files/Safety/1738837934.png') }}" alt="Image">
3. Create Storage Symlink
Run this command:
php artisan storage:link
4. Fix File Permissions
Set correct permissions:
chmod -R 775 storage public/storage
sudo chown -R www-data:www-data storage public/storage
5. Clear Cache & Restart Server
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
php artisan serve
storage
folder, thensymlink
to thepublic
directory, then display the images from there via theasset('storage/...')
helper. Also yes, share your actual code next time so we don't have to guess at your approach/errors. – Tim Lewis Commented Feb 6 at 15:17