In php, I am trying to read a file located above the root of the website (for example, /home/[username]/games/ ). I am trying to read a .swf and .xml file. It works fine for me on my local LAMP server using this code:
@readfile("/home/[username]/games/hangman/example.xml");
But, testing it on an external server, it does not work. There are no php errors in the log, but when I try file_exists() , it returns false. I checked and double checked that the file exists in this path.
The permissions for the files seem to be correct (they match my local server), and the file owner is the correct user.
Edit
A little update; I followed what @gnur had to say and set my base name in my httpd.conf in the virtual host setup, like:
php_admin_value open_basedir "/:/home/[username]/games/"
I tried setting it to a different value before, and it threw an error:
open_basedir restriction in effect. File(/home/[username]/games/example.xml) is not within the allowed path
Now I just get permission denied error when trying to read the file. Therefore, I am wondering if the rights to the file or the owner are not right.
These are my current permissions for the folder in the games directory:
drwxrwxr-x 2 [username] [username] 4.0K Jun 1 10:13 hangman
And then the files under this directory (the ones I'm actually trying to access):
-rwxrwxr-x 1 [username] [username] 293 Jun 1 10:13 example.xml -rwxrwxr-x 1 [username] [username] 204K Jun 1 10:13 hangman.swf