RE: [PHP] getting the phsyical path
| From: | Vail, Warren | Date: | Fri, 03 Dec 2004 21:00:36 +0000 |
| Subject: | RE: [PHP] getting the phsyical path | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203472@lists.php.net to get a copy of this message | ||
Another option would be to open the file with a http protocol reference.
PHP can access files specifying a URL, and if pointing to your current
domain it should work.
http://www.php.net/manual/en/function.fopen.php
I.e. $fh = fopen("http://www.mydomain.com/filea.txt","r");
You should also be able to get the hostname from the $_SERVER array,
depending on your web server
$_SERVER["HTTP_HOST"] on my linux apache server.
Good luck,
Warren Vail
> -----Original Message-----
> From: John Nichel [mailto:john@kegworks.com]
> Sent: Friday, December 03, 2004 11:56 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] getting the phsyical path
>
>
> Josh Howe wrote:
> > Sorry if this is a dumb question. Is there a way in php to get the
> > physical path the document root of my website? I want to
> open a file
> > in the root of my web server, i.e. "/", but I won't always
> know what
> > the physical path to the web root is, and it will vary depending on
> > the machine the web app is running on. I've tried using "realpath"
> > (e.g.
> > realpath("/")) but it doesn't really work. Thanks.
> >
> >
>
> $_SERVER['DOCUMENT_ROOT']
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> john@kegworks.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>