Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By nathan_czh on
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
I think one of these should
I think one of these should work
$logo_dir="sites/default/files/logo/";
or
$logo_dir="public://sites/default/files/logo/";