Here is a snippet of the code that I created to search for a file..recursively open the directories and search for a match..
<?php
function search($target, $directory){
     
    if(is_dir($directory)){
        $direc = opendir($directory);
        while(false !== ($file = readdir($direc))){
            
            if($file !="." && $file != ".."){
                if(is_file($directory."/".$file)){
                    if(preg_match("/$target/i", $file)){
                                            echo "<a href=\"$directory/$file\">$file</a><br>";
                                        }
                }else if(is_dir($directory."/".$file)){
                    search($target,$directory."/".$file);
                    
                }
            }
        }
        closedir($direc);
    }
    return ;
}
?>