Search code examples
phpapachecodeigniterfilepathcodeigniter-url

Codeigniter File Paths


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.


Solution

  • 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");