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

wari's avatar
Level 1

Displaying images on shared hosting

Hi,

I've created symbolic link at local PC, where its working fine, but I've uploaded same it to shared hosting, it is not working there. Basically I've images in the storage folder home/storage/public/images/

I want to display them by getting

$path=asset('storage/images/'.name.jpg); so the problem is in the shared hosting this way

$path=asset('storage/images/'.name.jpg); getting from the domain directory not from the parent directory, so for that there is no way to create symbolic link on shared hosting so what should I do to get images from the parent directory. I am beginner please one can help me to solve this problem. Thanks

0 likes
4 replies
closer01's avatar

hi, change path to :

{{ url('/images/name.jpg') }}

it will work.

wari's avatar
Level 1

I did but not working it

jlrdw's avatar

Just make your own constant to the files then

<td class="imgtd"><img src="<?php echo IMGFOLDER . 'upload/imgdogs/' . $row->dogpic; ?>" alt="" class="image"></td>

Where IMGFOLDER is a constant of your choice.

If you do not know how to define a constant please refer to the php manual, but something like

define('IMGFOLDER', '/yoursite/where_ever/some_where/');

Depending on your setup, play with the Leading slash, sometimes needed, sometimes not.

Snapey's avatar

If you cannot create a symbolic link on your shared hosting, you have two options

  1. Change the location of the files so that they are in the public folder (or ideally a subfolder of public)

  2. Find a new hosting provider

Any solution which gets files from the storage folder without a symbolic link is ONLY doing it because the web server is misconfigured and insecure.

Please or to participate in this conversation.