note 30867 added to function.realpath

From: Date: Tue, 01 Apr 2003 16:33:19 +0000
Subject: note 30867 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-46086@lists.php.net to get a copy of this message
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!!.. -- http://www.php.net/manual/en/function.realpath.php http://master.php.net/manage/user-notes.php?action=edit+30867 http://master.php.net/manage/user-notes.php?action=delete+30867 http://master.php.net/manage/user-notes.php?action=reject+30867

« previous php.notes (#46086) next »