Search
 
SCRIPT & CODE EXAMPLE
 

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 
";
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: php rand int 
Php :: drop column table in migration if exist in laravel 
Php :: How to change site url using wp-config.php 
Php :: Laravel stop on first validation error 
Php :: instalar php 7.4 no ubuntu 
Php :: how to print string plus variable in php 
Php :: Unable to locate package php7.4 for kali 2021 
Php :: laravel elequent get 
Php :: php function crop image 
Php :: laravel value eloquent 
Php :: php sort array by value 
Php :: accessing json data in php 
Php :: laravel validation custom message 
Php :: php .= 
Php :: explode example in php 
Php :: php password verify 
Php :: how to include file in php 
Php :: wc php if is product category page 
Php :: show images laravel 8 showJobImage($filename) 
Php :: mobile detect in laravel 
Php :: get last element of array php 
Php :: php check if link exists 
Php :: How To Unset Or Delete An Element From Array By Value In PHP? 
Php :: get filesize php 
Php :: Installing Maatwebsite excel import export package 
Php :: foreign key in laravel 9 
Php :: storepublicly laravel 
Php :: ternaire echo isset php 
Php :: update codeigniter 
Php :: laravel trim string blade 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =