if(!isset($_SERVER["DOCUMENT_ROOT"])) {$_SERVER["DOCUMENT_ROOT"]=substr($_SERVER['SCRIPT_FILENAME'] , 0 , -strlen($_SERVER['PHP_SELF'])+1 ); } it simply works! chris at vault5 dot com 30-Nov-2005 11:17 Since $_SERVER['DOCUMENT_ROOT'] is not always present, the following will provide it where $_SERVER dosen't. <?php function resolveDocumentRoot() { $current_script = dirname($_SERVER['SCRIPT_NAME']); $current_path = dirname($_SERVER['SCRIPT_FILENAME']); /* work out how many folders we are away from document_root by working out how many folders deep we are from the url. this isn't fool proof */ $adjust = explode("/", $current_script); $adjust = count($adjust)-1; /* move up the path with ../ */ $traverse = str_repeat("../", $adjust); $adjusted_path = sprintf("%s/%s", $current_path, $traverse); /* real path expands the ../'s to the correct folder names */ return realpath($adjusted_path); } |