Welcome Guest, Not a member yet? Register   Sign In
[Solved] How to pick up main application folder from another directory.
#1

[eluser]riwakawd[/eluser]
Just have been trying to use FCPATH to pick up main application folder. I have an sub folder which contains another index.php and application folder. As shown in images

Because I have a sub folder with own index.php and application. The FCPATH is picking up that location

Code:
<td>&lt;?php echo FCPATH . 'application/config/database.php'; ?&gt;</td>
<td class="align_right">&lt;?php echo is_writable(FCPATH . 'application/config/database.php') ? '<span class="text-success">Writable</span>' : '<span class="text-danger">Unwritable</span>'; ?&gt;</td>

The above html make display C:\xampp\htdocs\codeigniter\install\application/config/database.php

What would like it to be. Trying to pick up the application folder up one or two levels basically
C:\xampp\htdocs\codeigniter\application/config/database.php With out install.

I would like it to be able to pick up main application folder and not the one in the install folder.
#2

[eluser]Tim Brownlaw[/eluser]
So if you only want to wonder up one level

One way is to use dirname(FCPATH); instead of FCPATH!
That'll take you up One Level and remember that it is a path!

But you'd could also use dirname(__FILE__) and create a new define based upon that...
You could also use str_replace to replace the "install/" with nothing, thus removing it...

As you can see, there are various ways.

#3

[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1400326802"]So if you only want to wonder up one level

One way is to use dirname(FCPATH); instead of FCPATH!
That'll take you up One Level and remember that it is a path!

But you'd could also use dirname(__FILE__) and create a new define based upon that...
You could also use str_replace to replace the "install/" with nothing, thus removing it...

As you can see, there are various ways.

[/quote]

I also tried this <td>&lt;?php echo $_SERVER["DOCUMENT_ROOT"] . '/application/config/database.php'; ?&gt;</td> but did not pick up the project folder in my xampp.

C:/xampp/htdocs/application/config/config.php

trying to get it

C:/xampp/htdocs/codeigniter/application/config/config.php
#4

[eluser]riwakawd[/eluser]
[quote author="Tim Brownlaw" date="1400326802"]So if you only want to wonder up one level

One way is to use dirname(FCPATH); instead of FCPATH!
That'll take you up One Level and remember that it is a path!

But you'd could also use dirname(__FILE__) and create a new define based upon that...
You could also use str_replace to replace the "install/" with nothing, thus removing it...

As you can see, there are various ways.

[/quote]

Your way worked thanks so much.

Code:
<tr>
<td>&lt;?php echo dirname(FCPATH) . '/application/config/config.php'; ?&gt;</td>
<td class="align_right">&lt;?php echo is_writable(dirname(FCPATH) . '/application/config/config.php') ? '<span class="text-success">Writable</span>' : '<span class="text-danger">Unwritable</span>'; ?&gt;</td>
</tr>




Theme © iAndrew 2016 - Forum software by © MyBB