【发布时间】:2021-10-08 21:17:12
【问题描述】:
在我的 laravel 7.x 应用程序中,所有上传的文件都存储在 storage/app/public/<user-uuid-as-directory>
例如:storage/app/public/a6d4b3cb-a823-11eb-bfce-fcaa149efd09/72c2881d-a824-11eb-bfce-fcaa149efd09.png
当我尝试访问该文件时,我收到404 错误。
文件系统.php
...
'images' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL') . '/images',
'visibility' => 'public',
],
...
some.blade.php
$uuid = auth()->user()->token; // 'a6d4b3cb-a823-11eb-bfce-fcaa149efd09'
@foreach($images as $image)
<img src="{{ Storage::disk('images')->url($uuid . '/' . $image) }}" />
@endforeach
我在这里做错什么了..?
【问题讨论】:
-
尝试在
url的filesystem.php中将images更改为storage。 -
同时使用
php artisan config:clear清除配置缓存。 -
试过了,不行。
-
另外,您是否创建了从 public/storage 到 storage/app/public 的符号链接?
-
那么可能是权限问题。确保服务器对存储目录及其子目录具有读取权限
标签: php laravel directory storage