Location of file (fopen)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
This is something I always have trouble keeping straight. Assume I have a
file tree as follows:


My web pages are under either public_html or public_html.dir1. If I want to
create a file under public_html/dir2, in php, is the correct command

     $FL = fopen("/home/me/public_html/dir2.filename", "w");
     $FL = fopen("/dir2.filename", "w");

What effect does "open_basedir" have on this - and how can I, as a PHP user
be sure how this parameter is set.

Thanks in advance, everyone.

Re: Location of file (fopen)

Michael Satterwhite wrote:
Quoted text here. Click to load it

File paths in PHP file system functions are relative to the root
directory not relative to server's "document root". Therefore you need
to use:

$FL = fopen("/home/me/public_html/dir2.filename", "w");

or better:

$FL = fopen("/dir2.filename", "w");


Site Timeline