[英]How to check whether a file is exists in any one of the folders of the root directory
[英]Check if file exists on parent directory (from root) is impossible?
我想知道为什么我无法检查父目录中是否存在文件(不是来自root而不是来自上层目录)
if(file_exists('../1.txt'))
{
echo 'File Exists!';
}
else
{
echo 'File Is Not Exists!';
}
或者是否无法检查父目录中是否存在文件?
今天我遇到了同样的问题。 我在文件夹中有一个MVC处理程序
(app root)/mvc(/controller.php)
并想要一个文件夹,然后进入数据文件夹打开一个xml。 我的路径是:“../ data / foo.xml”。 它没有用。
但后来它告诉我:由于我在app根目录中包含了index.php中的mvc / controller.php,因此控制器“不知道”它位于根文件夹中的include。 从那里它只需要是“data / foo.xml”。
我不确定这是否是你的解决方案,或者这是你的意思“我正在检查2个差异位置”,但我强烈相信,对于一些看起来问题影响的开发者来说,它可能是解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.