473,382 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to get the document root (public html folder)?

Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache
1.31. I made a
lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move
my application to a Windows environment, running on an IIS web server,
the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I
always get an empty string).

Question: What is a cross-web server way of finding the path to the
document root -- the path to the public html folder?

Thanks for your help, - Dave
Jul 17 '05 #1
3 4640
D. Alvarado <"D. Alvarado" <la***********@zipmail.com>> wrote:
Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache
1.31. I made a
lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move
my application to a Windows environment, running on an IIS web server,
the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I
always get an empty string).

Question: What is a cross-web server way of finding the path to the
document root -- the path to the public html folder?

Thanks for your help, - Dave


For most scripts you could try to obtain your current working directory and
remove the path given in REQUEST_URI (or maybe another one, that fits
better).

var_dump($_SERVER) should help you.
--
Simon Stienen <http://dangerouscat.net> <http://slashlife.de>
»What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done.«
-- Sherlock Holmes in "A Study in Scarlet" by Sir Arthur Conan Doyle
Jul 17 '05 #2

"D. Alvarado" <la***********@zipmail.com> wrote in message
news:9f**************************@posting.google.c om...
Hello, I am running PHP 4 on my Fedora Core 2 dev machine, Apache
1.31. I made a
lot of calls to $_SERVER['DOCUMENT_ROOT']. Unfortunately, when I move
my application to a Windows environment, running on an IIS web server,
the variable $_SERVER['DOCUMENT_ROOT'] is no longer supported (I
always get an empty string).

Question: What is a cross-web server way of finding the path to the
document root -- the path to the public html folder?

Thanks for your help, - Dave


You must have something wrong with your server setup because I am running
PHP on Windows XP and all the $_SERVER variables are there. However, I am
running Apache, not IIS, so the fault must be with IIS. What shows up when
you run phpinfo()?

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #3
*** Tony Marston escribió/wrote (Wed, 22 Sep 2004 10:09:29 +0100):
You must have something wrong with your server setup because I am running
PHP on Windows XP and all the $_SERVER variables are there. However, I am
running Apache, not IIS, so the fault must be with IIS. What shows up when
you run phpinfo()?


I believe you need to have PHP as Apache module to get the DOCUMENT_ROOT
variable. Otherwise, PHP has no way to know such details from virtual
hosts.

basedir() and $_SERVER['PHP_SELF'] can be a good start.
--
-+ Álvaro G. Vicario - Burgos, Spain
+- http://www.demogracia.com (la web de humor barnizada para la intemperie)
++ Las dudas informáticas recibidas por correo irán directas a la papelera
-+ I'm not a free help desk, please don't e-mail me your questions
--
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: toufik toufik | last post by:
Hi, I've a web site in the address http://mySite.com in the root, I've a file index.html I've some subfiolders insid root/sub1/sub2 I like to add an html file (or php) index.html that call...
17
by: rox.scott | last post by:
Can someone please explain why this happens? The expected output is 3, but uncommenting line 7 makes the output 0. Why ??? VB.NET code: ** note the commented line, this is the culprit ** Dim...
1
by: news.microsoft.com | last post by:
Hello, How can i link to a document in the root folder of my asp.net app. I do not know at runtime wherein my subfolder i'm. I just want to link to a document in my root folder. Many Thanks in...
19
by: Steve Franks | last post by:
I am using VS.NET 2005 beta 2. When I run my project locally using the default ASP.NET Development Web Server it runs using a root address like this: http://localhost:11243/testsite/ However...
3
by: Nalaka | last post by:
Hi, I have an asp.net web application (www.myWebSite), and a subweb application (www.myWebSite/subSite). How do I set it so that, subweb application (www.myWebSite/subSite) be the root...
0
by: Nata | last post by:
hi all i am trying to store the XML Document object into MS SQL2005 i want to store this as whole not different tables; plz help me regarding this i am trying form last two weeks i asked many...
3
by: rkhurana | last post by:
Hi I am writing a JSF application that uses some third party charts. While I can see the chart but the javascript that is supposed to calla function to update chart periodically has a problem. It...
5
by: jhurrell | last post by:
I have been having some trouble getting my XSL style sheet to parse correctly. I have some XML outputted from an SQL-Server, that I then need to turn into multiple HTML files. This I have done...
10
by: Simon Brooke | last post by:
The DOM API has included public Node importNode(Node,boolean) as a method of the Document interface for a long time. Does anything actually implement it? Xerces 2 is giving me: ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.