i am trying to use the php function readdir to read the sites/default/files directory, but i keep getting the error message :The system cannot find the path specified (code :3). Is there any way to read the directory? Below is the code i am using

$logo_dir=$_SERVER["SERVER_NAME"].$base_path."sites/default/files/logo/";
$handle=opendir($logo_dir);
$counter=0;
$site_list=array();
if($handle = opendir($logo_dir)){
	echo $logo_dir;
	while (false !== ($entry = readdir($handle))) {
			$site_list[$counter]=$entry;
			$counter+=1;
	}
}

Comments

nevets’s picture

I think one of these should work

$logo_dir="sites/default/files/logo/";

or

$logo_dir="public://sites/default/files/logo/";