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
Laravel 5 Displaying image
提问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 resources
folder is notweb accessible.
Laravel 5resources
文件夹不可通过网络访问。
The asset()
helper's URLs start from the public
directory. Move resources/assets/img/champions/Ahri.png
to public/resources/assets/img/champions/Ahri.png
(or anywhere else in public
) and it'll work.
该asset()
助手的网址,从一开始public
的目录。移动resources/assets/img/champions/Ahri.png
到public/resources/assets/img/champions/Ahri.png
(或 中的任何其他地方public
),它会起作用。