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

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -