InMotion Hosting Support Center

How do I access files below / outside of public_html using php?

Category: How To

2013-03-31 1:20 am EST

Hits: 4,426
For my web site, my public directory is /public_html . BUT my line:
<?php include('includes/file.php'); ?>
fails because php cannot open the stream file.php. "includes" is off of public_html.


You must login before you can ask a follow up question.

You must login before you can submit an answer.



5,399 Points
2013-04-01 10:08 am EST
Hi RonaldGans,

Option 1: ../

To access a file / folder below your current directory, you can use ../

For example:

<?php include('../includes/file.php'); ?>

Option 2: Absolute Path

You can also use the absolute path, as in:

<?php include('/home/userna5/includes/file.php'); ?>

In the above example, you'll need to be sure to replace userna5 with your cPanel username.

I hope this helps!

- Brad

You must login before you can post a comment about this answer.

Like this Question?

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!