anandmainali5's avatar

Voyager image broken after uploading in server

I uploaded my project into the root directory in cpanel and the public folder in a 'public_html'. Now when i add a image the image are not showing . How to fix it?

0 likes
5 replies
bobbybouwmann's avatar

Laravel is by default storing images in the public directory. So you need to make a small change to your application so it uses the public_html instead of public directory

You only need to change the bootstrap/app.php and add below lines

$app->bind('path.public', function() {
    return base_path() . '/public_html';
});

Let me know if you have more questions!

marcellopato's avatar

Dear @bobbybouwmann , my app doesn´t work too. I´ve published my site as it is on my local computer, the public folder is INSIDE the application and I´ve changed the apache2 conf file to point to /var/www/htm/primorossi/public

How should I proceed in this case, please?

bobbybouwmann's avatar

@marcellopato Without any other information I can't really help you. What do you see? What does work? What doesn't work?

Just create a new thread so we can help you ;)

anandmainali5's avatar
anandmainali5
OP
Best Answer
Level 2

I have solved the issue by changing the config/filesystem.php root & url value as per the project structure,

'public' => [
            'driver' => 'local',
            'root' => storage_path('/public/images'),
            'url' => env('APP_URL').'/images',
            'visibility' => 'public',
        ],

Hope it will help others..

Aminul_Chowdhury's avatar
    'public' => [
        'driver' => 'local',
        'root' => storage_path('../storage/app/public'),
        'url' => env('APP_URL').'/storage/app/public',
        'visibility' => 'public',
    ],

It's work for me. You can try.

Please or to participate in this conversation.