The given PHP example helps you to clean a directory. Code Example:
<?php $dir2clean = 'test'; // directory to be clean $test = false; $output = ''; if ($handle = opendir($dir2clean)) { $header = "\n"; $i = 0; while(false !== ($file = readdir($handle)) && $i < 105) { if ($i < 105){ $output .= "<tr><td>$file</td>\n<td>"; if (substr($file, 0, 1) != '.'){ if ($test) $output .= 'test'; elseif (unlink("{$dir2clean}/{$file}")) $output .= "deleted"; else $output .= "kept"; } else $output .= ' '; $output .= "</td><td>"; $output .= date ("F d Y H:i:s.", fileatime("{$file}")); $output .= "</td>\n</tr>\n"; } $i++; } closedir($handle); } ?> Date: <?php echo date('d-m-Y H:i'); ?><br /> Directory: <?php echo $dir2clean; ?><br /> Files: <table border='1' cellpadding="2" cellspacing="0"> <?php echo $output; ?> </table>