英文:
how to display a picture on laravel?
问题
我正在尝试在Laravel上显示图片。
我已经这样做了:<img src="public/medoc.jpg" alt="Toxic Project">
。
为了确保100%不是链接问题,我在终端上写了public/medoc.jpg
,它可以显示图片。
我尝试在欢迎视图上显示它。
我已经尝试过:"{{ asset('public/medoc.jpg') }}"
。
有什么问题吗?谢谢。
英文:
i'm trying to display picture on laravel.
I did that : <img src="public/medoc.jpg" alt="Toxic Project">
.
To be sure at 100% it is not a link problem i writed public/medoc.jpg
on terminal and it's launch the picture.
I try to diplay it on the welcome view.
I have alredy tried with : "{{ asset('public/medoc.jpg') }}"
What's wrong ? thanks
答案1
得分: 5
asset()助手由Laravel提供,已经引用了public文件夹。
所以你需要做的就是:
<img src="{{asset('medoc.jpg')}}">
剩下的Laravel会为你处理。
英文:
The asset() helper provided by Laravel is already referencing to the public folder.
So all you need to do is :
<img src="{{asset('medoc.jpg')}}">
And Laravel will do the rest for you.
答案2
得分: 3
"如果你使用asset,那意味着你已经在public文件夹中,所以不需要写public...尝试这个..."
"{{asset('medoc.jpg)}}"
英文:
> if you use asset that means you are already in public folder so no need to write public..try this one..
"{{asset('medoc.jpg)}}"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论