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

you have many ../ in path. need go 1 level common ancestor of backend directory , file. should ../forecast/forecast.json


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -