2009-12-07, 02:33:24
ccagle8 Wrote:I did try that originally but i had problems with absolute/relative paths.
I need to find out how to use DEFINE() to set a global variable that always gives me the same (and correct path). If you look thru a lot of the code, I am constantly doing things like '../../data' -- always trying to keep things with a relative path. This works if you always use the file the same way, but as soon as you try to include one script into another script in a different folder, the '../../' (relative paths) no longer point to the correct place. uugghh
I have no idea if that makes sense to anyone... hopefully it does and then someone can point me to the right direction I need to go...
hi!
i think this an architecture problem... try to find out the depth or your current path from document root (works under windows as well):
Code:
function getDepth() {
$doc_root = substr($_SERVER['DOCUMENT_ROOT'], -1) == DIRECTORY_SEPARATOR ? substr($_SERVER['DOCUMENT_ROOT'], 0, -1) : $_SERVER['DOCUMENT_ROOT'];
if ($current != $doc_root) {
$depth = count(explode(DIRECTORY_SEPARATOR, str_replace($doc_root, '', $current))) - 1;
}
return isset($depth) ? str_repeat('..' . DIRECTORY_SEPARATOR, $depth) : '';
}
for a "clean" document root you can set a global constant like this:
Code:
define('DOCROOT', substr($_SERVER['DOCUMENT_ROOT'], -1) == DIRECTORY_SEPARATOR ? substr($_SERVER['DOCUMENT_ROOT'], 0, -1) : $_SERVER['DOCUMENT_ROOT']);
another suggestion: upgrade to newest uploadify