【问题标题】:Symlink storage link from Laravel doesn't work as expectedLaravel 的符号链接存储链接无法按预期工作
【发布时间】:2019-06-20 10:07:31
【问题描述】:

我正在使用以下代码通过 laravel 上传图片:

$logoPath = $request->file('logo')->store('uploads/clients');

一切正常,文件上传到storage/app/uploads/clients/

然后,我运行命令php artisan storage:link 以公开创建符号链接并成功创建。问题是这个符号链接只显示“storage/app/public”中的文件,但正如我所说,我的图像保存在storage/app/uploads/clients

我已经在其他项目中做过这个过程并且效果很好,我真的不知道这次我做了什么不同。

有什么想法吗?

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    您似乎正在使用默认磁盘local 将文件存储在storage/app 目录中,如config/filesystems.php 中配置的那样,但您想要的是public 磁盘将文件存储在storage/app/public 中通过运行php artisan storage:link 链接到公共目录。

    所以这里有一些解决方案:

    • 指定您要使用的磁盘:

      $request()->file('logo')->store('uploads/clients', ['disk' => 'public']);
      

    • config/filesystems.php 中创建一个新磁盘并将其与您的uploads/clients 链接,然后将config/filesystems.php 中的默认FILESYSTEM_DRIVER 更改为新磁盘。

    • config/filesystems.php中的默认FILESYSTEM_DRIVER更改为public

    【讨论】:

      猜你喜欢
      • 2013-05-11
      • 2019-01-11
      • 2012-11-02
      • 2018-06-20
      • 1970-01-01
      • 2011-01-25
      • 1970-01-01
      • 2010-11-26
      • 1970-01-01
      相关资源
      最近更新 更多