Laravel,未显示来自公共文件夹的图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42271368/
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, not displayed image from public folder
提问by Katrin_cage
I have problem with displaing images from public directory:
我在显示公共目录中的图像时遇到问题:
<img src="{{asset('public/front/images')}}/index/logo.jpg">
Image looks like this.
图像看起来像这样。
from another folders images are displaed correctly
来自另一个文件夹的图像正确显示
<img src="{{url('/')}}/images/banner1.jpg" >
回答by ukalpa
Laravel has some rewrite rules to rewrite you url path. The static files may not be accessed due to following reasons: 1. Check the permission of your folders, "chmod -R 777 folder" in Linux or authenticate the permission to anyone for the folder in Windows, then try again. 2. Check the web server configure if it restrcits the folder to be accessed. 3. Check your route if there is any route/resource/route::group has the same name with the folder.
Laravel 有一些重写规则来重写你的 url 路径。由于以下原因,静态文件可能无法访问: 1. 检查您的文件夹的权限,Linux 中的“chmod -R 777 文件夹”或 Windows 中对该文件夹的任何人的权限验证,然后重试。2. 检查网络服务器配置是否重新访问要访问的文件夹。3. 检查你的路由是否有与文件夹同名的路由/资源/路由::组。
By the way, you can put your static files in another folder which is out of the base_path() in Laravel, then set a alias in the web server to let it be accessed. In case, this method makes the structure more clear.
顺便说一句,您可以将静态文件放在 Laravel 中 base_path() 之外的另一个文件夹中,然后在 Web 服务器中设置别名以允许访问。以防万一,这种方法使结构更加清晰。
回答by Parth Vora
Try this:
尝试这个:
<img src="{{ asset('front/images/index/logo.jpg'); }}">
You don't need to use publicprefix with asset().
您不需要在asset() 中使用公共前缀。
回答by Rupali Pemare
Check this one
检查这个
<html>
<body>
<img src="{{ URL::asset('/front/images/index/logo.jpg') }}" />
</body>
</html>