CodeIgniter Forums
how to reference file one folder up and down? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: how to reference file one folder up and down? (/showthread.php?tid=65634)



how to reference file one folder up and down? - mrad - 07-04-2016

I am trying to reference a file one folder up and then down a few folders:

   

PHP Code:
include "../common/KoolControls/KoolGrid/koolgrid.php"

But this does not work, when the 'include' is in the file views/actors (see above)

Can anyone enlight me?

Thanks in advance.


RE: how to reference file one folder up and down? - pdthinh - 07-04-2016

(07-04-2016, 02:47 PM)mrad Wrote: I am trying to reference a file one folder up and then down a few folders:



PHP Code:
include "../common/KoolControls/KoolGrid/koolgrid.php"

But this does not work, when the 'include' is in the file views/actors (see above)

Can anyone enlight me?

Thanks in advance.

Try this
PHP Code:
$path rtrim(__DIR__'/') . '/';
$path .= "../common/KoolControls/KoolGrid/koolgrid.php";
include 
$path



RE: how to reference file one folder up and down? - John_Betong - 07-04-2016

(07-04-2016, 09:07 PM)pdthinh Wrote:
(07-04-2016, 02:47 PM)mrad Wrote: I am trying to reference a file one folder up and then down a few folders:



PHP Code:
include "../common/KoolControls/KoolGrid/koolgrid.php"

But this does not work, when the 'include' is in the file views/actors (see above)

Can anyone enlight me?

Thanks in advance.

Try this
PHP Code:
$path rtrim(__DIR__'/') . '/';
$path .= "../common/KoolControls/KoolGrid/koolgrid.php";
include 
$path

Paths are not easy Sad

If the included path does not work I usually echo getcwd(); and adjust the requested relative path.

Once working remove the echo getcwd();


RE: how to reference file one folder up and down? - natanfelles - 07-04-2016

PHP Code:
$this->load->view('common/KoolControls/KoolGrid/koolgrid');