Reply to Re: open_basedir

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация