导航栏中的Laravel纵断面图像
我有导航栏中的Laravel纵断面图像,laravel,laravel-5.4,Laravel,Laravel 5.4,我有userprofile表,它与user表有关系,在userprofile表中我有userImg存储图像名称的地方,当我从主页加载图像时,它工作正常,例如: <img src="../storage/profil/{{Auth::user()->userprofile->userImg}}"> userprofile->userImg}> 但是,当我进入一个页面,其中存储/profil距离3点或1点远,但它无法正常工作时,将图像加载到导航栏的最佳方式是什么 请注意,
userprofile
表,它与user
表有关系,在userprofile
表中我有userImg
存储图像名称的地方,当我从主页加载图像时,它工作正常,例如:
<img src="../storage/profil/{{Auth::user()->userprofile->userImg}}">
userprofile->userImg}>
但是,当我进入一个页面,其中存储/profil距离3点或1点远,但它无法正常工作时,将图像加载到导航栏的最佳方式是什么
请注意,我的导航栏位于一个名为includes
的文件中,我将其包含在master
层中
Laravel 5.4使用url()
-
userprofile->userImg)}“alt=”…”>
首先,您必须创建从public/storage
目录到storage/app/public
目录的符号链接,以便访问文件。您可以通过以下方式实现:
php artisan storage:link
并通过以下方式将其作为资产访问:
<img src="{{asset('storage/profil/Auth::user()->userprofile->userImg')}}">
userprofile->userImg')}>
查看完美,我每天都会学到很多东西,我能假设当我给出url时,它会出现在公共文件夹中并从那里继续吗?啊,是的,我已经链接了它,我从一个页面开始访问它,但不是每一个页面。但我假设资产是另一种方式。谢谢你的回答
<img src="{{asset('storage/profil/Auth::user()->userprofile->userImg')}}">