Search code examples
phpapachefilestreamdigital-ocean

failed to open stream: No such file or directory


I now upload my project to server in digital ocean,but I get this error in apache2 error log

require_once(/var/www/html/example/v1../include/DbHandler.php): failed to open stream: No such file or directory

The 2 line that occur error is this,is working well in localhost,but when go to server it having the error above

require_once '../include/DBHandler.php';
require_once '../include/PassHash.php';

My directory is as below,I have to required DBhandler.php which in include folder,and index.php is from v1 folder(the place that require_once calling from).

-include
  -DBhandler.php
  -PassHash.php
-v1
  -index.php

Here is the error log I got

[Fri May 19 12:33:19.621030 2017] [:error] [pid 5236] [client 115.133.247.14:575 22] PHP Warning: require_once(/var/www/html/example/v1../include/ DbHandler.php): failed to open stream: No such file or directory in /var/www/htm l/example/v1/index.php on line 9

What I tried so far

require_once $_SERVER['DOCUMENT_ROOT'].'/include/DBHandler.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/include/PassHash.php';

And this,but none of this solve the problem

require_once __DIR__."/../include/DBHandler.php";
require_once __DIR__."/../include/PassHash.php";

Someone please help!Give me the a right direction,so I can proceed


Solution

  • Your require :

    require_once '../include/DbHandler.php';
    

    Your filename:

    DBhandler.php
    

    The name is different. Change your require to:

    require_once '../include/DBHandler.php';