php - file_get_contents does not find file -
the following code tries load file content string.
// loads forecast json public function loadforecast() { try { $filename = "../../forecast/forecast.json"; echo "dateiname: '" . $filename . "'\n"; echo "pfad: '" . realpath($filename) . "'\n"; if ($forecastcontent = file_get_contents($filename) !== false) { echo "got content"; } else { echo "no content"; } } catch (exception $e) { echo "caught exception: " . $e->getmessage(); } }
can tell me fault? i'm getting "no content". realpath print "" (empty string).
my webspace hierachie is
- /
- backend
- my php file
- forecast
- forecast.json
- backend
you have many ../
in path. need go 1 level common ancestor of backend
directory , file. should ../forecast/forecast.json
Comments
Post a Comment