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

Avatar
  • Answered
For my web site, my public directory is /public_html . BUT my line: fails because php cannot open the stream file.php. "includes" is off of public_html. RON
Avatar
BradM
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! Thanks, - Brad