FredAt Posted December 4, 2009 Share Posted December 4, 2009 Hello All, This is probably a very basic question but I cannot for the life of me figure out how to correctly refer to a file located above the document root. $path = $_SERVER['DOCUMENT_ROOT'].'/../fldr_name/file.name'; is not giving the correct result. In answer to the inevitable question - I want to store a SQLite database in a folder above the server root for security. Naturally, I will need to access the file from some of my PHP scripts. I am sure I have done this before and it has worked. Maybe it is just late in the day or maybe I am plain thick :'(. I'd appreciate any help. Link to comment https://forums.phpfreaks.com/topic/184010-path-to-file-above-document-root/ Share on other sites More sharing options...
premiso Posted December 4, 2009 Share Posted December 4, 2009 I believe the DOCUMENT_ROOT adds the first slash for you, try this: $path = $_SERVER['DOCUMENT_ROOT'].'../fldr_name/file.name'; If that does not work echo out $path and see where it could be going wrong, alternatively you can use explode at the / and put the items in an array and just remove the last item in the array. Link to comment https://forums.phpfreaks.com/topic/184010-path-to-file-above-document-root/#findComment-971468 Share on other sites More sharing options...
FredAt Posted December 4, 2009 Author Share Posted December 4, 2009 Thanks. Rule 1 (which I know well and break often) - never work beyond the point of uttter fatigue. I started off by forgetting to create the safe SQLite database directory. Then I had too many slashes. Then I tested locally and got it right, uploaded to my Linux server and found it did not work. Eventually I realized that it was not liking my \ slashes and expected / slashes instead. Enough for today! Link to comment https://forums.phpfreaks.com/topic/184010-path-to-file-above-document-root/#findComment-971507 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.