laravel, how to store images to public_html directory

≯℡__Kan透↙ 提交于 2019-12-24 07:59:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!