Laravel 5 显示图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31147874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:51:54  来源:igfitidea点击:

Laravel 5 Displaying image

phplaravellaravel-5

提问by Josh Kirkpatrick

I am trying to display an image stored in /resources/assets/img/champions/

我正在尝试显示存储在 /resources/assets/img/champions/ 中的图像

with

     <img class="img-rounded"
           src="{{asset("/resources/assets/img/champions/Ahri.png")}}"
                style="width:32px;height:32px;">

Which gives me this output

这给了我这个输出

<img class="img-rounded" 
src="http://localhost:8000/resources/assets/img/champions/Ahri.png" style="width:32px;height:32px;">

from what i know this should display the image right?

据我所知,这应该正确显示图像?

going to the path in the browser so

转到浏览器中的路径

http://localhost:8000/resources/assets/img/champions/Ahri.png

gives me

给我

NotFoundHttpException in compiled.php line 8140:

回答by ceejayoz

The Laravel 5 resourcesfolder is notweb accessible.

Laravel 5resources文件夹不可通过网络访问。

The asset()helper's URLs start from the publicdirectory. Move resources/assets/img/champions/Ahri.pngto public/resources/assets/img/champions/Ahri.png(or anywhere else in public) and it'll work.

asset()助手的网址,从一开始public的目录。移动resources/assets/img/champions/Ahri.pngpublic/resources/assets/img/champions/Ahri.png(或 中的任何其他地方public),它会起作用。