无法打开流:没有这样的文件或目录

failed to open stream: No such file or directory

我现在将我的项目上传到数字海洋中的服务器,但我在 apache2 错误日志中收到此错误

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

出现错误的第 2 行是这样的,在本地主机上运行良好,但是当转到服务器时出现上述错误

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

我的目录如下,我必须在include文件夹中要求DBhandler.php,而index.php来自v1文件夹(require_once 调用自)。

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

这是我得到的错误日志

[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

到目前为止我尝试了什么

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

还有这个,但是none这个解决了问题

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

有人请帮忙!给我一个正确的方向,所以我可以继续

可能是你的文件名大小写:DBHandler intead of DbHandler

您的要求:

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

您的文件名:

DBhandler.php

名称不同。 将您的要求更改为:

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

只需删除文件路径开头的符号 / this 即可解决您的问题。

require_once(var/www/html/example/v1../include/DbHandler.php): 无法打开流:没有那个文件或目录