Codeigniter文件路径 [英] Codeigniter File Paths
问题描述
很抱歉,但是我对codeigniter中的文件路径有些困惑,因为您可能会或可能不会知道CI会按以下方式布置其文件系统:
sorry to bother but I am having some confusion with filepaths within codeigniter, as you may or may not know CI lays out its file system as follows:
-application:
-controllers
-views
-models
-system(contains CI framework)
我已经创建了一个css文件,并将一些图像保存在资源文件夹中,如下所示:
I have created a css file and have some images saved in the a resources folder like so:
-application:
-controllers
-views
-models
-system(contains CI framework)
-resources
-img001
-style.css
我在想,是否有人可以指出正确的方向来使用相对路径访问资源文件夹.
I was wondering whether someone could point me in the right direction to accessing the resources folder using relative paths.
推荐答案
您可以使用base_url函数.要使用此功能,您必须加载url helper
You can use base_url function. To use this function you have to load url helper
您可以按如下所示在任何需要的地方加载:
You can load wherever it required as below:
$this->load->helper('url');
或者您可以在autoload.php中进行设置.
Or you can set in autoload.php.
echo base_url("resources/img001/img_name.jpg");
echo base_url("resources/style.css");
这篇关于Codeigniter文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!