Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Clear and delete the folder after the time specified in php

<?
$days = 1;
$dir = dirname ( __FILE__ );

$nofiles = 0;

    if ($handle = opendir($dir)) {
    while (( $file = readdir($handle)) !== false ) {
        if ( $file == '.' || $file == '..' || is_dir($dir.'/'.$file) ) {
            continue;
        }

        if ((time() - filemtime($dir.'/'.$file)) > ($days *86400)) {
            $nofiles++;
            unlink($dir.'/'.$file);
        }
    }
    closedir($handle);
    echo "Total files deleted: $nofiles 
";
}
?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Clear #delete #folder #time #php
ADD COMMENT
Topic
Name
7+2 =