Forum Moderators: coopster

Message Too Old, No Replies

How know the web path (some servers have public_html dir, others other

How know the web path (some servers have public_html dir, others other

         

astrix

6:31 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



How know the web path (some servers have public_html dir, others other)

Is possible know with PHP which is the real web path?

In some servers FTP connect directly to the web path, others have subdirectories and the public_html are the real web path... Others use other name (www for example)...

Is possible retrieve from PHP which is the real web path?

Well, in reality me problem is more complex, I pass to a script the ip, username and password of a remote server and I want to automatically upload a file to the web root directory of the remote server via ftp (ftp_connect, ftp_login... etc) and I not find how to know with code which is the web root directory, not all servers have public_html, other the web root directory is www and others connect directly via ftp to the web root directory...

I am searching in the web for the answer and no find the solution... Well, but I think is logical that has to be possible to know the web root directory...

Thanks in advance...!

jusdrum

6:42 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Hi astrix, welcome to Webmaster World!

The web root path is stored in the $_SERVER['DOCUMENT_ROOT'] variable. This will tell you the root of the current web site.

There are many of these kinds of variables stored in the environment when a script is running. See PHP's predefined variables [us3.php.net] for a comprehensive list.

Hope this helps!

astrix

7:26 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Thanks jusdrum, but $_SERVER['DOCUMENT_ROOT'] not is valid because I need the web root of the remote server accesed by ftp, with $_SERVER['DOCUMENT_ROOT'] I retrieve the web root directory of the php file that do the connection, not the web root directory of the web accessed by ftp...

Thanks jusdrum...

jusdrum

7:31 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Ah, I mis-read your post. Sorry about that.

It sounds like you may have to pass the web root on a case by case basis. I don't know of any functions in PHP that will grab the remote web root, if there is, it sounds like a nasty security issue. :-)

astrix

8:02 pm on Mar 29, 2005 (gmt 0)

10+ Year Member



Well, appear in this other forum the answer is possible find... Not is sure, but is interesting

[edited by: coopster at 11:46 pm (utc) on Mar. 30, 2005]
[edit reason] No urls please (TOS [webmasterworld.com]) [/edit]

coopster

11:54 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not aware of any way you are going to be able to get the DOCUMENT_ROOT value on a remote server this way. Typically, if you are given the userid and password, you will have an idea what the web root realpath is in advance.

astrix

1:53 am on Mar 31, 2005 (gmt 0)

10+ Year Member



In reality is some for comfort, for connect directly via ftp to the web root dir, bur also for automatization in some process...

This question is also valid for the winsock dll and activex - also not are info, or I not find, of how know wath is the web root dir -, is the same, how make a ftp program that connect directly always to the web root directory...

For example, you have various webs and want to perfom some operations via ftp automatically and need to upload archives to the web root, instead of insert for each ftp connection wath is the web root dir for upload - lost time - is possible to automatize...

I think in some place must be which is that web root dir, but I not find solution... Not find also in documentation of winsock...