Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 846
TotalNewbie Avatar asked Feb 13 '14 12:02

TotalNewbie


2 Answers

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)

like image 64
Egor Sazanovich Avatar answered Oct 04 '22 08:10

Egor Sazanovich


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");
like image 34
Kumar V Avatar answered Oct 04 '22 08:10

Kumar V