haku Posted September 27, 2010 Share Posted September 27, 2010 I need to find a way to resolve a relative path outside the document root, in a cross-platform friendly manner. My users have a settings page where they are able to set the path to a folder where files should be included. This path may not exist at the time of saving the setting. The given path is then retrieved from the database when files are being saved, the path is checked to see if a folder needs to be created, and the file is saved to the path. Two possible paths they may use are: * files (This is the webpath: http://site.com/files or absolute path /home/user/public_html/files) * ../files (This is the absolute path: /home/user/files where the webroot is /home/user/public_html/) The first path is easy to deal with. However, I'm having a rough time resolving the second path into a usable system path (i.e. /home/user/files). This needs to be cross platform compatible (windows/'Nix). I've played around with realpath(), but I'm just not finding something that works for me. Any suggestions? Quote Link to comment Share on other sites More sharing options...
btherl Posted September 27, 2010 Share Posted September 27, 2010 Can you post your code, along with the expected results and actual results? Quote Link to comment Share on other sites More sharing options...
chintansshah Posted September 27, 2010 Share Posted September 27, 2010 I suggest, to use $_SERVER['DOCUMENT_ROOT'] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.