<?php
if ( isset($_POST['dirname']) )
{
echo $dir_name = $_POST['dirname'];
if ( is_file( $dir_name ) )
{
if ( unlink($dir_name) ) echo "Del file \"$dirname\" successfully!
";
else echo "Fail to del file \"$dirname\"!
";
}
else
{
CleanDir($dir_name);
if ( rmdir($dir_name) ) echo "Remove dir \"$dirname\" successfully!
";
else echo "Fail to Remove dir \"$dirname\"!
";
}
}
function CleanDir($dir)
{
$handle=opendir($dir);
while ( $file=readdir($handle) )
{
if ( ($file==".") || ($file=="..") ) continue;
if ( is_dir("$dir/$file") )
{
CleanDir("$dir/$file");
if ( rmdir("$dir/$file") ) echo "Remove dir \"$dir/$file\" successfully!
";
else echo "Fail to Remove dir \"$dir/$file\"!
";
}
else
{
if ( unlink("$dir/$file") ) echo "Del file \"$dir/$file\" successfully!
";
else echo "Fail to del file \"$dir/$file\"!
";
}
}
closedir($handle);
}
?>
無標題文件