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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stallingjohn
Forum Newbie
Posts: 6
Joined: Mon Apr 23, 2007 2:16 am

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

Post 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
djot
Forum Contributor
Posts: 313
Joined: Wed Jan 14, 2004 10:21 am
Location: planet earth
Contact:

Post 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
-
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please be more precise with path/path , path1/path2, and so on.
Best if you just copy&paste the real values.
nyfael
Forum Commoner
Posts: 32
Joined: Thu Sep 21, 2006 2:28 am

Post 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
stallingjohn
Forum Newbie
Posts: 6
Joined: Mon Apr 23, 2007 2:16 am

Thanks Mr.nyfael

Post by stallingjohn »

Hi nyfael I tried it and it worked thanks for your super valuable suggestions
Post Reply