Neha_26's avatar

Images not rendering in Laravel on Shared Hosting (Works on Localhost) | Symlink & Path Issue`

Hi everyone,

I'm developing an ad marketplace where I generate PNG previews of Blade templates using an external API (HCTI). Everything works perfectly on localhost, but I'm facing a critical issue on my live server (Shared Hosting).

The Problem:

Images uploaded via Livewire (stored in storage/app/public/ads/content) are not appearing in the Blade templates on the live site.

Oddly, .AVIF images work in the generated previews, but .JPG and .PNG do not.

Standard asset('storage/...') calls return broken links across the entire site.

What I've Tried:

I attempted to run php artisan storage:link, but my host restricts the symlink() PHP function, resulting in a 500 Server Error.

I've updated my .env APP_URL to the live domain and cleared the config cache.

I tried converting images to Base64 strings before sending them to the API. This fixed the preview generation for some files, but the rest of the website is still "image-blind".

Current Theory: > It seems to be a Base Path issue where the live server cannot resolve the virtual public/storage directory because the physical symlink is missing/blocked.

Has anyone found a robust way to serve storage files on shared hosting without a symlink, or a way to force Laravel's asset() helper to point to the actual physical path?

Thanks in advance!

0 likes
3 replies
jlrdw's avatar

If you search past post there is detail on this. Basically you can serve images by creating an image controller such as:

    public function displayImage()
    {
        $basedir = "/stohere/uploads";
        $imagedir = Request::input('dir');
        $image = Request::input('img');
        $file = $basedir . '/' . $imagedir . '/' . $image;
        return response()->file($file, array('Content-Type' => 'image/jpeg'));
    }

But there is more detail in plenty of past post covering this.

Of course for secure images you implement authorization.

Snapey's avatar

store the files directly in the public folder would be one solution.

Please or to participate in this conversation.