我有userprofile
表与user
表有关系,在userprofile
表中我有userImg
我存储图像名称,当我从主页加载图像时,它工作正常,如:
<img src="../storage/profil/{{Auth::user()->userprofile->userImg}}">
但是当我进入一个页面,其中存储/轮廓是3点或1点距离它没有正常工作时,将图像加载到导航栏的最佳方法是什么?
请注意,我的导航栏位于名为includes
的文件中,我将其包含在master
图层
Laravel 5.4
答案 0 :(得分:2)
使用url()
-
<img src="{{url('storage/profil/'.Auth::user()->userprofile->userImg)}}" alt="...">
答案 1 :(得分:1)
首先,您必须创建从public/storage
目录到storage/app/public
目录的符号链接,以便您可以访问这些文件。你可以用:
php artisan storage:link
并将其作为资产访问:
<img src="{{asset('storage/profil/Auth::user()->userprofile->userImg')}}">