Question

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)

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.

Was it helpful?

Solution 2

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');

Or you can set in autoload.php.

echo base_url("resources/img001/img_name.jpg");
echo base_url("resources/style.css");

OTHER TIPS

echo FCPATH."resources/img001/img_name.jpg";
echo FCPATH."resources/style.css";

Constant FCPATH will return system's path to Your front controller's file (index.php at root of Your CI-App)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top