define('PATH', 'dir/'); function destroy($dir) { $mydir = opendir($dir); while(false !== ($file = readdir($mydir))) { if($file != "." && $file != "..") { chmod($dir.$file, 0777); if(is_dir($dir.$file)) { chdir('.'); destroy($dir.$file.'/'); rmdir($dir.$file) or DIE("couldn't delete $dir$file<br />"); } else unlink($dir.$file) or DIE("couldn't delete $dir$file<br />"); } } closedir($mydir); } destroy(PATH); echo 'all done.';
You can delete That Folder. Then Delete all files Inside that folder. <?php if (!is_dir('folder_name')) { mkdir('folder_name'); } rmdir('folder_name'); ?> Code (markup):
This code will delete all the files from the folder/directory you specify $dir = 'your/directory/'; foreach(glob($dir.'*.*') as $v){ unlink($v); }
How to expect files from get removed Like for examples 2 files which is : index.php ( Index file ). delete.php ( The file which delete other files content the code ). delete file will be in same folder content other files with multi extensions.. other files .php other files . rar other files . xxx