【问题标题】:Issue with Laravel Symbolic LinksLaravel 符号链接的问题
【发布时间】:2018-03-28 07:48:37
【问题描述】:

storage/app/public 中的每个用户都有特定的文件夹。 我将 public_path 动态更改为:

$storageConfig = Config::get('filesystems.disks.public');
$storageConfig['root'] = storage_path('app/public/').$userString ;
config()->set('filesystems.disks.public', $storageConfig);

当用户上传他的照片时,它会保存在路径中

storage/app/public/$userString/profile_pictures

我使用 php artisan 命令创建了链接:

php artisan storage: link

但是我在显示图像时遇到了这个问题。 使用符号链接,图像显示为:

  <img src="{{asset('storage/').$profilepicture}}">

图片未加载。可能是什么问题?有人可以帮忙吗?

【问题讨论】:

  • 如果你这样做会怎样:&lt;img src="{{asset('storage/'.$profilepicture)}}"&gt;
  • @Ahsan 这不起作用
  • 你在改变中间件的路径吗?
  • @SérgioReis 是的
  • 在你的 .blade 中,如果你尝试这个,它会输出什么{{Storage::disk("public")-&gt;getDriver()-&gt;getAdapter()-&gt;getPathPrefix()}}

标签: php laravel laravel-5 storage


【解决方案1】:

要从存储中调用图像,您应该使用内置帮助器:

例如

<img src="{{ Storage::url($userString. '/profile_pictures/' .$profilepicture) }}">

see here

这将在使用 php artisan storage:link 后起作用

【讨论】:

  • 已更新,生成的源中的链接是否正确?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-10-13
  • 2019-07-28
  • 1970-01-01
  • 2021-01-28
  • 1970-01-01
  • 2019-01-11
相关资源
最近更新 更多