|
Posted by Janwillem Borleffs on 06/25/06 09:59
sreniaw@wp.pl wrote:
> My read file - test.txt is in open_basedir path.
> When I use full path to the file everything is ok.
>
> Do you have any clue ?
>
Image the following situation:
The text and script files are in the following dir:
/somedir/subdir
The script file includes the text file relatively to the current working
dir, as in:
readfile('test.txt');
The open_basedir directive is set as follows:
open_basedir = /somedir/subdir
Now, you cd to /somedir/subdir and execute the script: all is fine.
Next, you cd to /somedir and execute the script: it fails. Why?
Because you include the text file relatively to the current working dir
(cwd), PHP expects the text file to be in /somedir, simular to:
readfile('/somedir/test.txt');
And this is restricted, hence the error message. For this reason, using an
absolute path works, because this doesn't take the cwd into account.
The same applies to the safe_mode settings, which you also seem to use
according to the "Not owner" error.
To dynamically determine the absolute path, you could do something like:
readfile(dirname($_SERVER['PHP_SELF']) .'/test.txt');
HTH;
JW
Navigation:
[Reply to this message]
|