public static function autoclean($path, $time = -1)
    {
        $path = self::resolve($path);

        if ($path !== false && is_dir($path) && ($dh = opendir($path))) {
            if ($time < 0) {
                $time = App::env('appdata_expires');
            }

            $expires = REQUEST_TIME - $time;
            $path .= '/';

            while (false !== ($file = readdir($dh))) {
                $current = $path . $file;

                if (is_file($current) && filemtime($current) < $expires) {
                    unlink($current);
                }
            }

            closedir($dh);

            $dh = null;
        }
    }
public static function autoclean($path, $time = -1)
    {
        $path = self::resolve($path);

        if ($path !== false && is_dir($path) && ($dh = opendir($path))) {
            if ($time < 0) {
                $time = App::env('appdata_expires');
            }

            $expires = REQUEST_TIME - $time;
            $path .= '/';

            while (false !== ($file = readdir($dh))) {
                $current = $path . $file;

                if (is_file($current) && filemtime($current) < $expires) {
                    unlink($current);
                }
            }

            closedir($dh);

            $dh = null;
        }
    }
public static function autoclean ( $ path , $ time = - 1 ) { $ path = self :: resolve ( $ path ) ; if ( $ path !== false && is_dir ( $ path ) && ( $ dh = opendir ( $ path ) ) ) { if ( $ time < 0 ) { $ time = App :: env ( 'appdata_expires' ) ; } $ expires = REQUEST_TIME - $ time ; $ path .= '/' ; while ( false !== ( $ file = readdir ( $ dh ) ) ) { $ current = $ path . $ file ; if ( is_file ( $ current ) && filemtime ( $ current ) < $ expires ) { unlink ( $ current ) ; } } closedir ( $ dh ) ; $ dh = null ; } }
Clear old files in a folder from storage path

@param string $path
@param int    $time
@return void
Clear old files in a folder from storage path