Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tomasosho's avatar

Symlink working, but image not loading when hosted in shared hosting.

Locally all my images load just fine, but once hosted on shared hosting, it stops loading even after creating symlink. When i try loading the image url i get 404 error

0 likes
14 replies
tomasosho's avatar

@Snapey Yes. I've hosted several small laravel projects on shared hosting. This one's giving me an issue i've never encountered before. I can't display images saved in storage folder even after symlink. It's still the same, I try getting the images via url and i get 404 error. I'm using php 8.1, Laravel 9. I really do not know what to do?

Snapey's avatar

@tomasosho look on your server. is the image saved? what folder is it in?

Do you see public in your urls?

tomasosho's avatar

@Snapey The image is saved, it's saved in /storage/nimage/ This is the image link url/storage/nimage/AK286312_1647009320_1647886628.jpg but it brings up 404 error. No public in my urls

tomasosho's avatar

@jlrdw I used terminal to create it. It got created successfully. It's still giving the same result 404 error for the image link

jlrdw's avatar

@tomasosho try the asset helper to display the image, example:

<img src="<?php echo asset('assets/upload/imgdogs') . '/' . $row->dogpic; ?>" alt="" class="image">

Change assets/upload/imgdogs to your use case. I use asset helper in apache and nginx.

tomasosho's avatar

@jlrdw It's still the same, Is there a possibility that my php version 8.1 might be causing it?

tomasosho's avatar

Tested everything in terminal to confirm it exists

[nihmqdqb@server72 ~]$ ls -al /home/nihmqdqb/hol/storage/app/public
total 52
drwxr-xr-x 10 nihmqdqb nihmqdqb 4096 Mar 21 19:23 .
drwxr-xr-x  3 nihmqdqb nihmqdqb 4096 Mar 18 10:33 ..
-rw-r--r--  1 nihmqdqb nihmqdqb 6148 Mar 18 10:34 .DS_Store
-rw-r--r--  1 nihmqdqb nihmqdqb   14 Feb 22 10:42 .gitignore
lrwxrwxrwx  1 nihmqdqb nihmqdqb   30 Mar 21 19:23 app -> /home/nihmqdqb/hol/storage/app
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 10 11:33 conference_image
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 10 11:33 contract
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 10 18:21 contract_image
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 11 09:36 fool
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 17 10:17 image
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 21 11:29 nimage
lrwxrwxrwx  1 nihmqdqb nihmqdqb   37 Mar 21 19:23 public -> /home/nihmqdqb/hol/storage/app/public
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 10 09:10 technical_advisory_committee_image
drwx------  2 nihmqdqb nihmqdqb 4096 Mar 10 18:26 technical_image
[nihmqdqb@server72 ~]$ ls -al /home/nihmqdqb/public_html/storage
lrwxrwxrwx 1 nihmqdqb nihmqdqb 37 Mar 21 19:28 /home/nihmqdqb/public_html/storage -> /home/nihmqdqb/hol/storage/app/public
[nihmqdqb@server72 ~]$ ls -al /home/nihmqdqb/public_html/storage/nimage
total 18832
drwx------  2 nihmqdqb nihmqdqb    4096 Mar 21 11:29 .
drwxr-xr-x 10 nihmqdqb nihmqdqb    4096 Mar 21 19:23 ..
-rw-r--r--  1 nihmqdqb nihmqdqb  226035 Mar 21 11:29 2017-04-09-PHOTO-00000065_1647876566.jpeg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:07 AK286313_1646928445.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:08 AK286313_1646928487.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:08 AK286313_1646928538.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:10 AK286313_1646928620.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:13 AK286313_1646928837.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:18 AK286313_1646929126.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:20 AK286313_1646929203.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:20 AK286313_1646929247.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:21 AK286313_1646929293.jpg
-rw-r--r--  1 nihmqdqb nihmqdqb 1902511 Mar 10 11:33 AK286313_1646929997.jpg
tomasosho's avatar

My permission was set to 0777 instead of 0755

Please or to participate in this conversation.