Feststellen ob ein Verzeichnis vorhanden ist

radarin

Angesehenes Mitglied
Hallo Zusammen

Ich möchte feststellen, ob sich im Verzeichnis' bilder' das unterverzeichis 'thumb' befindet.

CODE if(opendir(".../bilder/thumb") == "false"){...}else{...}


Die Auswertung funktioniert allersings nicht, bekomme immer das Selbe. Dafür kommt eine Fehlermeldung wenn das Verzeichnis nicht existiert.
 
hi

probier mal:
<?php
/*
* Function to check recursively if dirname is exists in directory's tree
*
* @param string $dir_name
* @param string [$path]
* @return bool
* @author FanFataL
*/
function dir_exists($dir_name = false, $path = './') {
if(!$dir_name) return false;

if(is_dir($path.$dir_name)) return true;

$tree = glob($path.'*', GLOB_ONLYDIR);
if($tree && count($tree)>0) {
foreach($tree as $dir)
if(dir_exists($dir_name, $dir.'/'))
return true;
}

return false;
}
?>
 
Zurück
Oben