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

时间:2018-04-17 09:43:42

标签: php laravel file upload

在我的托管上,我有'public_html',而不是' public'目录名称I. 我已将公共路径绑定到public_html directory in index.php文件

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

现在public_path()帮助器返回带有public_html的路径(正确)

更重要的是,我的磁盘位于filesystem.php文件

'my_upload' => [
        'driver' => 'local',
        'root' => public_path().'/images/adverts',
        'visibility' => 'public',
    ],

一切看起来都不错,但是当我上传一些文件时,laravel将它们放在'public' directory中。我需要在'public_html'中使用它们。

(我需要公共目录中的图像因为我的托管不提供链接做存储文件夹)

提前致谢

1 个答案:

答案 0 :(得分:0)

尝试存储这样的文件:

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