Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

File being writen to the wrong directory.

7:52 pm on Feb 5, 2008 (gmt 0)

New User

10+ Year Member

joined:Nov 23, 2006
votes: 0

Hi, I've been having problems writing to a text file on my server. I am using php to write the file. I have created a directory above my document root and I want to store a cache file in there. The problem I am having is that the file is still being writen to the document root even though I have defined the absolute path to where the file is supposed to go. I have no idea why this would happen. The php script can find the file but can't open it or read it. The permissions on the file are 775.

rehat linux.
apache 2.0.52
php 5.1.2

9:14 pm on Feb 5, 2008 (gmt 0)

New User

10+ Year Member

joined:Nov 23, 2006
votes: 0

Ok I think I 've found what is causing the problem. "open_basedir restriction in effect". How do I fix this?
1:29 am on Feb 6, 2008 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 31, 2003
votes: 6

This is a PHP issue, and a security measure - check out the
entry here:


open_basedir string
Limit the files that can be opened by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off.

When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it's not possible to avoid this restriction with a symlink. If the file doesn't exist then the symlink couldn't be resolved and the filename is compared to (a resolved) open_basedir

You should be able to add the path for the script to the list of allowed values.