简体   繁体   中英

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.

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 . The linux based OS using strict case sensitive naming system.

So try to fix that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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