Failed to open stream : No such file or directory
In PHP scripts, whether calling include()
, require()
, fopen()
, or their derivatives such as include_once
, require_once
, or even, move_uploaded_file()
, one often runs into an error or warning:
Failed to open stream : No such file or directory.
What is a good process to quickly find the root cause of the problem?
There are many reasons why one might run into this error and thus a good checklist of what to check first helps considerably.
Let's consider that we are troubleshooting the following line:
require "/path/to/file"
Checklist
1. Check the file path for typos
or move whatever is called by require*
or include*
to its own variable, echo it, copy it, and try accessing it from a terminal:
$path = "/path/to/file";
echo "Path : $path";
require "$path";
Then, in a terminal:
cat <file path pasted>
上一篇: PHP错误信息“注意:使用未定义的常量”是什么意思?
下一篇: 无法打开流:没有这样的文件或目录