Originally posted by desikida
View Post
PHP Code:
<?php
include 'pclzip.lib.php';
$dir = 'path/hmm'; //without last slash
$pattern = '*.zip';
gum_remove_files_in_dir($dir,$pattern);
function gum_remove_files_in_dir($dir,$pattern)
{
$arr = glob($dir.'/'.$pattern);
foreach($arr as $file)
{
//PUT YOUR ZIP EXTRACTION CODE HERE
$zip = new PclZip($file);
$zip->extract(PCLZIP_OPT_PATH, $dir);
}
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if(is_dir($dir.'/'.$file))
{
gum_remove_files_in_dir($dir.'/'.$file,$pattern);
}
}
}
closedir($handle);
}
}
?>
btw, you should use unlink instead of rmdir to delete file.
Leave a comment: