note 30867 deleted from function.realpath by aidan

From: Date: Sun, 29 Aug 2004 21:51:19 +0000
Subject: note 30867 deleted from function.realpath by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75615@lists.php.net to get a copy of this message
Note Submitter: rcarvajal at users dot sf dot net ---- this seems to do the trick: // Images Upload dir $iud = realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/../images/'); always remember: add a slash ( / ) at the begining and the end of the string. this is very simple: first get the filesystem directory name of the current script. then add a / and back one directory with .. then enter the directory images /images/ and get the realpath of that: example: http://server.com/admin/addproduct.php $_SERVER['SCRIPT_FILENAME'] = /home/user/public_html/project/admin/addproduct.php then applying dirname to that you get: /home/user/public_html/project/admin then you must add the slashes and point to another dir: /home/user/public_html/project/admin/../images/ then you can safely run realpath on that: realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/../images/'); and you will get: /home/user/public_html/project/images hope this help someone!!..

« previous php.notes (#75615) next »