in the most shared servers the default public folder is named public_html or www, whats may present a problem since the server document root and Laravel public folder are not the same.
Let's fix it following this 3 steps:
That´s it, just do it.
In app/Providers/AppServiceProvider.php
add to the function register()
:
$this->app->bind('path.public', function() {
return base_path('public_html');
});
In bootstrap/app.php
add at the end of the file but before return $app;
:
$app->bind('path.public', function() { return base_path().'/public_html'; });
this will bind Laravel document root with the correct one, in this case we are linking it to public_html folder, you can also put the full path to your document root instead of the dynamic approach.
I have tested (and used) this only in Laravel 8 and 9, I have not tested it in later versions due to shifting a lot of my work to GO, but I invite you to try it and if you have time leave your comment for future reference for others.