【发布时间】:2018-08-10 09:34:02
【问题描述】:
我正在尝试显示 storage/app/public 文件夹中的图像。每当我的控制器使用
从该文件夹中检索图像时$images = Storage::files('public');
从此处检索的文件以public/ 为前缀,而不是storage/。
这导致的问题是可以找到图像localhost/storage/filename.jpg,但无法找到localhost/public/filename.jpg 或localhost/storage/public/filename.jpg。
我可以通过手动切断公共前缀并将其替换为存储来解决此问题,但这并不是一种特别优雅的处理方式。
我已经运行了命令 php artisan storage:link 并重新运行它会产生 The "public/storage" directory already exists. 消息。
【问题讨论】:
-
您的网址中不应包含
/public/。public应该是您项目的服务器 DocumentRoot。
标签: php laravel-blade laravel-5.6