Page 1 of 1

how can I know the path of file starting with "http://d

Posted: Wed May 30, 2007 1:50 am
by stallingjohn
I have a file in server.

It's location is:

/home/myonbiz/public_html/domainname/path1/path2/.../done.txt

how can I know the path of file starting with "http://domainname/path/done.txt" using php function.


when I try to print it using command

<?php
$path="path/path/done.txt";

$dir = $_SERVER['DOCUMENT_ROOT'].$path;

echo $dir;

?>

it gives

/home/myonbiz/public_html/domainname/path1/path2/.../done.txt

but I needed only http://domainname/path/done.txt

Posted: Wed May 30, 2007 2:29 am
by djot
-
Well, my experience is that each server handles variables like DOCUMENT_ROOT different, and there will always be a server that has a new variation of the paths/dirs/whatever.

Let's see what the others write down. Perhaps you should search the forum. This was answered already. If I remember correctly, feyd posted something already (with basedir() and so on).

djot
-

Posted: Wed May 30, 2007 2:42 am
by volka
please be more precise with path/path , path1/path2, and so on.
Best if you just copy&paste the real values.

Posted: Wed May 30, 2007 3:08 am
by nyfael
You don't want DOCUMENT_ROOT if you're looking for the http path.

You could try: "http://" . $_SERVER['HTTP_HOST'] . "/" . $path

-Kerry

Thanks Mr.nyfael

Posted: Thu May 31, 2007 4:58 am
by stallingjohn
Hi nyfael I tried it and it worked thanks for your super valuable suggestions