PHP刪除文件下多層文件

$cleanfileUrl = ROOT_PATH . 'public' . DS .'ttsaudio';
        $opendir = opendir($cleanfileUrl);
        while ($file=readdir($opendir)) {
            if($file!="." && $file!="..") {
                $fullpath=opendir($cleanfileUrl."/".$file);
                while ($path_date =  readdir($fullpath)){
                    if($path_date!="." && $path_date!="..") {
                        $audio_fullpath = $cleanfileUrl."/".$file.'/'.$path_date;
                        if(file_exists($audio_fullpath)){
                            unlink($audio_fullpath);
                        }
                    }
                }
                if(file_exists($cleanfileUrl."/".$file)){
                    rmdir($cleanfileUrl."/".$file);
                }
            }
        }
        closedir($opendir);
        closedir($fullpath);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章