PHP - Check if a file exists in a folder -
i wanna check if there image on folder server. have little function in php not working , don't know why:
$path = 'folder/'.$id; function check($path) { if ($handle = opendir($path)) { $array = array(); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && count > 2) { echo "folder not empty"; } else { echo "folder empty"; } } } closedir($handle); }
any appreciated, in advance.
it not work because count
coming nowhere. try instead:
$path = 'folder/'.$id; function check($path) { $files = glob($path.'/*'); echo empty($files) ? "$path empty" : "$path not empty"; }
Comments
Post a Comment