当前位置:网站首页>PHP get directory size

PHP get directory size

2022-06-26 12:23:00 ζ He Yiyi

   function dirsize($dir)
    {
    
        @$dh = opendir($dir);
        $size = 0;
        while ($file = @readdir($dh)) {
    
            if ($file != "." and $file != "..") {
    
                $path = $dir . "/" . $file;
                if (is_dir($path)) {
    
                    $size += dirsize($path);
                } elseif (is_file($path)) {
    
                    $size += filesize($path);
                }
            }
        }
        @closedir($dh);
        return $size;
    }
原网站

版权声明
本文为[ζ He Yiyi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170521402026.html