0
votes

How can i access a file outside of htdocs folder on windows? I have a config file outside of my root (htdocs) folder, in which i want to save off the configuration for my database connection, but when i call it, it says no file found.

i am cureently in the following directory: xampp\htdocs\includes

and my config file is in: \xampp\inc

i tried to echo the path, but i didn't get any output

echo realpath('../..inc/config.php') . PHP_EOL;

if (!file_exists('../../inc/config.php')) {
          throw new Exception("No config file found!");
        }
1
Is there a typo in the first path or did you miscopy?Dharman
At what stage does it say file not found? Is it at the stage where you try to echo the realpath() or does it get to throw the Exception?NaijaProgrammer
recheck the folder level. your code works fine for mentioned scenarioprasanna puttaswamy

1 Answers

1
votes

i got it to work with

$_SERVER['DOCUMENT_ROOT']) . '/inc/config.php'