资产文件未在 Laravel 中加载?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17785321/
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
Assets files not loading in laravel?
提问by open source guy
i am using Laravel 4
my base url is http://localhost/messifan/fms/laravel/public/
我正在使用 Laravel 4 我的基本网址是 http://localhost/messifan/fms/laravel/public/
my css in public/css/barcelona.css
我的 css public/css/barcelona.css
browser trying to load this URL
浏览器试图加载此 URL
http://localhost/messifan/fms/laravel/public/css/barcelona.css
i am using this code in view to load css
我正在使用此代码来加载 css
<?php echo URL::asset('css/barcelona.css'); ?>
I get this error trying to open http://localhost/messifan/fms/laravel/public/css/barcelona.css
尝试打开时出现此错误 http://localhost/messifan/fms/laravel/public/css/barcelona.css
回答by Blue Genie
The problem could be on your htaccess or permissions.
问题可能出在您的 htaccess 或权限上。
Try to temporarily remove htaccess and try to access directly the css file. If the problem persists then you should try to chmod
public/css
folder and the files in to 777 and try again.
尝试暂时移除 htaccess 并尝试直接访问 css 文件。如果问题仍然存在,那么您应该尝试将chmod
public/css
文件夹和文件放入 777 并重试。
Check again the path to the css file and its name.
再次检查 css 文件的路径及其名称。
回答by Itrulia
public/css folder and the files in to 777 and try again.
public/css 文件夹和 777 中的文件,然后重试。
thats a bad idea, make it 766, when the css folder is 777 everyone can execute scripts there.
那是个坏主意,将其设为 766,当 css 文件夹为 777 时,每个人都可以在那里执行脚本。
回答by kJamesy
Try
尝试
<?php echo HTML::style('css/barcelona.css'); ?>
Edit PS: This will load the styles. To access the path to the file, you don't need to do much! well, unless you want to put the link to it in your view:
编辑 PS:这将加载样式。要访问文件的路径,您不需要做太多事情!好吧,除非你想把它的链接放在你的视图中:
<a href="<?php echo URL::asset('css/barcelona.css'); ?>">The CSS File</a>