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: 7,050
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,
<h2>Option 1: ../</h2>
To access a file / folder below your current directory, you can use ../

For example:

<div class='code_block'>&lt;?php include('<span style='color:red;'>../</span>includes/file.php'); ?&gt;</div>
<h2>Option 2: Absolute Path</h2>
You can also use the absolute path, as in:

<div class='code_block'>&lt;?php include('<span style='color:red;'>/home/userna5/</span>includes/file.php'); ?&gt;</div>
In the above example, you'll need to be sure to replace userna5 with <a href=''>your cPanel username</a>.

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!