如何在Laravel上显示图片?

huangapple go评论111阅读模式
英文:

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 : &lt;img src=&quot;public/medoc.jpg&quot; alt=&quot;Toxic Project&quot;&gt;.

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 : &quot;{{ asset(&#39;public/medoc.jpg&#39;) }}&quot;

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 :

&lt;img src=&quot;{{asset(&#39;medoc.jpg&#39;)}}&quot;&gt;

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..

&quot;{{asset(&#39;medoc.jpg)}}&quot;

huangapple
  • 本文由 发表于 2020年1月7日 01:30:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/59616465.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定