Wednesday, August 3, 2011

Delete Files and folder and inside folder files using php - Clear Buffer

Delete Files and folder Using php:

html page:

< align="right"><small><a href="/clear.php?p=/var/www/checklist">clear buffer</a></small></div>


Clear.php :

<?php
if (isset($_REQUEST["p"]))
{
$paths = $_REQUEST["p"];
}
@$deldir = deletefolder($paths);
function deletefolder($paths)
{
if ($handlerm=opendir($paths))
{
while (false!==($filerm=readdir($handlerm)))
{
if ($filerm<>"." AND $filerm<>"..")
{
if (is_file($paths.'/'.$filerm))
{
@unlink($paths.'/'.$filerm);
}
if (is_dir($paths.'/'.$filerm))
{
deletefolder($paths.'/'.$filerm);
@rmdir($paths.'/'.$filerm);
}
}
}
}
closedir($dhvalid1);
}
echo "< style='color:red'>Successfully cleared</h1>";
?>

No comments:

Post a Comment