Hi,
I am using the Linux Server and server variable $_SERVER["DOCUMENT_ROOT"] to get the root folder to open a text file located in the folder for ex.
fopen($_SERVER["DOCUMENT_ROOT"]."/folder/file.txt","r");
......
I want to use the same scripts to work with Windows Server, Is there any way to get the root folder of the domain installation in Windows?
like it should return c:\www
Could any one suggest me?
Thanks in advance
Sakthi
6 8664
Heya, Sakthi.
$_SERVER['DOCUMENT_ROOT'] evaluates to the path to your server's document root regardless of operating system....
Heya,
I didn't find the variable $_SERVER["DOCUMENT_ROOT"] in the phpinfo() in the Windows server. How to enable this variable in Windows Server?
Sakthi
Heya, Sakthi.
... except for Windows, it seems, which likes to make life difficult.
Do you have $_SERVER['ORIG_PATH_TRANSLATED'] by any chance?
Alternatively, if you have a file at the document root, you can use dirname(__FILE__).
Hi,
Its working in Windows, but is not the situation,
I want a single variable that returns the document root in both servers,
here the _SERVER["ORIG_PATH_TRANSLATED"] variable is not available in my Linux Server.
For ex,
1. In Linux Server it should refer /www/project
2. Where as in Windows Server it should return D:\www\project
where project is the root for the particular project
Suggest me
Sakthi
Heya,
Actually the problem with dirname(__FILE__) is,
When I call this from the root, ie. from /www/projects it solves the situation.
The problem is, when I call from the sub directory inside the root ie.
From /www/projects/aaa, I want to refer the path /www/projects/bbb, here the function returns /www/projects/aaa as result, so the final result will be, dirname(__FILE__)."/bbb" = /www/projects/aaa/bbb which is wrong
Suggest me
Sakthi
Heya, Sakthi.
Try creating a common include file in your document root: -
<?php
-
if( empty($_SERVER['DOCUMENT_ROOT']) )
-
{
-
$_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
-
}
-
?>
-
Then simply include() this file at the top of any script that needs to use $_SERVER['DOCUMENT_ROOT'].
Sign in to post your reply or Sign up for a free account.
Similar topics
by: MeAndI |
last post by:
How to everybody,
how it is possible to change the value of the AUTH_USER server variable?
Is this possible?
If no, how I could change the logged user?
Thanks for help
|
by: Bob T |
last post by:
Hi All,
I am trying to pass a variable from my VB asp.net script (from for example
Sub Page_Load in mypage.aspx.vb) to my Client side script.
I have found and looked at a very good example...
|
by: joun |
last post by:
Hi all,
i want to create in my asp.net application a custom server variable, so i
can retrieve later in other pages (even asp or perl) with
request.servervariables("HTTP_mycustomvariable")
...
|
by: Tillman |
last post by:
I am working on reducing the size of the ViewState value passed between
client and server in a web app. And I am asking myself why the ViewState
value can't be stored in a server variable rather...
|
by: shil |
last post by:
Hi all,
I am using javascript confirm() function to get user's confirmation
from codebehind after a condition is met. I don't want to attach the
function to the button on page load. When I...
|
by: ndrw_cheung |
last post by:
Hi, all. I recently migrated a website from IIS5.0 (running on Windows
2000 Server SP4) to IIS6.0 (running Windows Server 2003 SP1). The
ASP.NET
version is upgraded from 1.1 to 2.0 as well. I...
|
by: mbasil77 |
last post by:
I'm trying to create a custom server variable in DOTNET. Is there a
way to do this?
I know there are MUCH better/easier ways to store session data ...
However, I'm dealing with a legacy...
|
by: rlm51 |
last post by:
Hey everyone, hope all are fine ...
Dreamweaver uses a login_user server behavior to send the user to a specified page on a successful login. Normally you would provide a url, but I would like to...
|
by: doublestack |
last post by:
I have a server variable that is being called from an aspx page in a WSS site. I need to find a way to remove part of the variable before passing it to the URL. The server variable is LOGON_USER......
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
| |