1
votes

I deployed a laravel app to shared hosting (hostinger). Everything is working fine except the images which are not showing up.

I have created a symlink of my storage folder with my public_html folder. Files uploaded enters the public folder but when I link the images they still do not show up.

I have created a symlink to the public_html since I cannot access the public folder. I need help on this please

I need the image to be displayed on the browser

2
You can't create symlinks on shared hosting ln linux command is disabledSalim Djerbouh
There's a Laravel command for linking images to the public folder: php artisan storage:link; images are uploaded into the storage folder, then symlinked to public. Are you using this approach? Or something custom?Tim Lewis
the public_html folder replaced the public folder. I used ssh to create a symlink already. the Link is between the public_html folder and the storage/app/public folder.Udodiri Anumadu
from my public_html folder i can see the symlinked folder but the link to the image does not work...Udodiri Anumadu
Is there anyway i can upload a screen shot here. so you can see what i really meanUdodiri Anumadu

2 Answers

0
votes

In default Laravel deployment the symlink is created in public folder as storage and links to ../storage/app/public.

In order to debug your problem, please have a look at the developer tools of your browser to find out whether it is a 404 or 403 problem (or even another).

Please check for correct permissions. Otherwise you may change the physical storage path to something inside the public folder. This avoids the requirement to create a symlink. Keep in mind to protect non-public storage via .htaccess for example.

0
votes

You have to the path to your public assets directory if it is not public directory in the root folder. In your case, the public assets directory is public_html. So please bind the path to it from the root folder.

class AppServiceProvider extends ServiceProvider
{

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if (App::environment('prod')) {
            $this->app->bind('path.public', function() {
                return base_path('../../public_html');
            });
        }
    }
}