首页 文章

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

提问于
浏览
0

在我的托管上,我有 'public_html' ,而不是'public'目录名称我已将公共路径绑定到 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

    尝试存储这样的文件:

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

相关问题