PHP uses the built-in Dir class to implement directory traversal removal, Phpdir
The example in this article describes how PHP uses the built-in Dir class to implement directory traversal removal. Share to everyone for your reference. The implementation method is as follows:
function Cleardir ($dir) {if (file_exists ($dir)) { if (!is_dir ($dir)) exit ("{$dir} is not a directory"); else { $dirObj = dir ($dir); while ($file = $DIROBJ->read ()) { if (Is_dir ($dir. ') /'. $file) && $file!== '. ' && $file!== ' ... ') { Cleardir ($dir. ') /'. $file); if (@!rmdir ($dir. ' /'. $file))
"; } ElseIf ($file!== ' && $file!== ' ... ') { if (unlink ($dir. ') /'. $file)) echo "{$file} file successfully deleted
"; } } } } else exit ("{$dir} does not exist");} Cleardir ('./demo ');
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/976696.html www.bkjia.com true http://www.bkjia.com/PHPjc/976696.html techarticle PHP uses the built-in Dir class to implement directory traversal removal, phpdir The example of PHP using the built-in Dir class to implement directory traversal removal method. Share to everyone for your reference. Concrete Implementation Method ...