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? Link to comment https://forums.phpfreaks.com/topic/214500-resolve-relative-path-outside-document-root/ 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? Link to comment https://forums.phpfreaks.com/topic/214500-resolve-relative-path-outside-document-root/#findComment-1116182 Share on other sites More sharing options...
chintansshah Posted September 27, 2010 Share Posted September 27, 2010 I suggest, to use $_SERVER['DOCUMENT_ROOT'] Link to comment https://forums.phpfreaks.com/topic/214500-resolve-relative-path-outside-document-root/#findComment-1116184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.