Codeigniter File Paths

sorry to bother, but I have some confusion with file paths inside codeigniter, as you may or may not know that CI sets out its file system as follows:

-application:
             -controllers
             -views
             -models
-system(contains CI framework)

I created a css file and have some images saved in the resources folder, for example:

 -application:
             -controllers
             -views
             -models
-system(contains CI framework)

-resources
     -img001
     -style.css

I was wondering if anyone could point me in the right direction to access the resource folder using relative paths.

+3
source share
2 answers

You can use the base_url function. To use this feature, you need to download the URL helper

You can download where necessary, as shown below:

$this->load->helper('url');

Or you can install in autoload.php.

echo base_url("resources/img001/img_name.jpg");
echo base_url("resources/style.css");
+4
source
echo FCPATH."resources/img001/img_name.jpg";
echo FCPATH."resources/style.css";

FCPATH (index.php CI-)

+5

All Articles