|
Posted by ACID on 08/23/06 20:47
Michael Satterwhite wrote:
> This is something I always have trouble keeping straight. Assume I have a
> file tree as follows:
>
> /home
> /home/me
> /home/me/public_html
> /home/me/public_html/dir1
> /home/me/public_html/dir2
>
> 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");
> -or-
> $FL = fopen("/dir2.filename", "w");
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("{$_SERVER['DOCUMENT_ROOT']}/dir2.filename", "w");
Paul
[Back to original message]
|