【发布时间】:2021-06-04 09:40:36
【问题描述】:
我的存储文件夹(laravel)中的图像很少,我想在我的 React 数据表中查看它们。显然它只显示图像的路径名。
【问题讨论】:
我的存储文件夹(laravel)中的图像很少,我想在我的 React 数据表中查看它们。显然它只显示图像的路径名。
【问题讨论】:
首先你已经创建了符号链接
php aritsan storage:link
这将在public folder 中创建shortcut storage 文件夹
这样你就可以访问网址
https:://urdomain/storage/filename
这里我假设您的文件图像存在于storage/app/public。如果您的文件包含在任何子文件夹中,那么它应该是
https:://urdomain/storage/subfoldername/filename.extension
参考:https://laravel.com/docs/8.x/filesystem#the-public-disk
如果你得到这样的 json 响应,也可以在 reactjs 中
{
"id": 23532,
"name": "john",
"image": "images/image.jpeg",
},
那么你可能需要附加baseurl
<img src="https:://urdomain/storage/{image}" alt='image' width='100%'/>
【讨论】: