Recursive Directory Delete Function
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ define('PATH', '/www/public/images/'); 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 "); } else unlink($dir.$file) or DIE("couldn't delete $dir$file "); } } closedir($mydir); } destroy(PATH); echo 'all done.'; ?>
0 comments:
Post a Comment