问题
On my hosting, I have 'public_html'
, not 'public' directory name I
I have bind public path to the public_html directory in index.php
file
$app->bind('path.public', function() {
return base_path().'/public_html';
});
now public_path() helper returns me path with public_html (correct)
What is more, i have my disk in the filesystem.php
file
'my_upload' => [
'driver' => 'local',
'root' => public_path().'/images/adverts',
'visibility' => 'public',
],
Everything looks fine for me, but when I upload some files, laravel put them in 'public' directory
. I need to have them in 'public_html'
.
(I need images in public directory becouse my hosting does not provide link do storage folder)
Thanks in advance
回答1:
try store files like this:
if(!Storage::disk('my_upload')->put($path, $file_content)) {
return false;
}
来源:https://stackoverflow.com/questions/49874806/laravel-how-to-store-images-to-public-html-directory