dongtun1872 2018-04-17 09:43 采纳率: 0%
浏览 256

laravel,如何将图像存储到public_html目录

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条回答 默认 最新

  • drbae3964 2018-04-17 09:47
    关注

    try store files like this:

    if(!Storage::disk('my_upload')->put($path, $file_content)) {
        return false;
    }
    
    评论

报告相同问题?