简体   繁体   English

如何使用PHP检查文件夹是否存在

[英]How to check if a folder exists using PHP

I have this code to check if a folder exists using PHP and it works correctly with xampp in windows, but when I try to move that page to a server, it doesn't work. 我有这段代码可以检查是否存在使用PHP的文件夹,并且该文件夹可以在Windows中的xampp上正常工作,但是当我尝试将该页面移至服务器时,它不起作用。

Here is my code: 这是我的代码:

  function validate (&$valores, &$errores, $campo, $carpeta) { $valores [$campo] = $carpeta; if ((file_exists($carpeta) && is_dir($carpeta))==false) { $errores[$campo] = true; } else { $errores[$campo] = false; } } 

There is an alternative to the code that I'm doing? 我正在执行的代码还有替代方法吗?

解决方案:我将PHP open_basedir文件夹和文件添加到我想更改的文件夹中,然后使用Filezilla修改了读取/写入权限并进行了修复。

您可以使用http://de.php.net/manual/en/function.opendir.php并检查是否为假。

Your code should operate fine on both platforms, so its not this issue. 您的代码在两个平台上都应该可以正常运行,因此不是这个问题。

Usually, such problem due to the naming system . 通常,这种问题归因于naming system The linux based OS using strict case sensitive naming system. 基于Linux的OS使用严格区分大小写的命名系统。

So try to fix that. 因此,请尝试解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM