无法从存储文件夹获取图像文件路径。我错过了什么?

Could not get the image file path from the storage folder. What am i missing?

这是将我的图像保存在 /storage/app/public 文件夹中的代码

$path = $request->file('question_image')->store('public');

laravel 5.3 文档说我必须创建一个符号 link 从 /public/storage 到 /storage/app/public 文件夹因此我使用命令

php artisan storage:link

至此,我已成功将图像存储在 /storage/app/public 中。

现在可以理解的是,我可以使用

获取这些文件
echo asset('storage/file_name.jpeg');

但没有任何运气。

请让我知道我在这里缺少什么?

如果您需要的是文件的 URL,请尝试此操作:url(Storage::url('public/photo.jpg));

否则只需使用 Storage::url('public/photo.jpg); 获取路径。

如果您想显示存储中的图像,您可以在 blade 文件中使用它:

<img src="{{asset('storage/image.jpg')}}">