Learn PHP filesystem, using its functions, you can easily bulk delete files and folders of remote server.
but must be careful, delete the wrong, regret yo!
Application Scenario: When we test some projects remotely, we do not need to delete, so as not to waste space, but also to prevent loopholes. But using FTP to delete very slowly, so upload this file, set up the folder you want to delete, directly run this URL is done!
[code= "PHP"]<?php
//php recursively delete directories and files
function Delall ($path) {
if (!is_dir ($path)) {
return false;
}
//Open Directory
$DH = Opendir ($path);
//Cyclic reading of directories
While (($file = Readdir ($DH))!== false) {
//filter out the current directory '. ' and up-level directory ' ... '
if ($file = = '. ' | | $file = = ' ... ') continue;
//If the file is a directory, enter the recursive
if (Is_dir ($path. ' /'. $file)) {
Delall ($path. ' /'. $file);
} else {
//If it is not a directory, delete it
unlink ($path. ' /'. $file);
}
}
//After exiting the loop (all files have been deleted at this time), close the directory and delete
Closedir ($DH);
rmdir ($path);
return true;
}
$path = './aa ';
Var_dump (Delall ($path));
[/code]
Original article:http://bbs.51cto.com/thread-1501963-1.html Welcome to come to discuss!
This article is from the "Colorful Pole" blog, please be sure to keep this source http://qicaiji.blog.51cto.com/1158325/1941642
Self-editing and emptying remote Web space weapon