Actually, I want to know the directory in which the PHP file being processed is located. For ex. if there is an index.php in c:/program files/apache group/apache2/htdocs/mysite/index.php ... then in the index.php file, I want a variable, say $myvar which should be equal to "c:/program files/apache group/apache2/htdocs/mysite" and if in Linux, then something like, "/usr/local/apache-126.96.36.199/htdocs/mysite" . Please help.
If your trying to use it in a link or something you can just use ./ for current dir or ../ for parent dir.
Actually i want it for an upload script. I want to get the current folder. say '$x'. Then, the file recieved is copied to $x/files. I am testing it on a windows server, but when i upload it, it might be a linux server, rather it is a linux server.
You can get the current work directory using the getcwd() function.
Then use it with the move_uploaded_file() function.
If I good understand your problem you are looking root function.
$index = $_SERVER['DOCUMENT_ROOT'] . "/index.php";
or if you would like to catch some other folder:
$other = $_SERVER['DOCUMENT_ROOT'] . "/someotherFolder/some.php";
Actually, comp615's solution worked exactly fine, even while uploading. I just copied the $_FILES['file']['tmp_name'] to ./files/$_FILES['file']['name']... and presto it worked in both, Windows and Linux. Thanks everybody.