php统计文件夹大小

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

  

posted @ 2015-12-31 15:17  浅痕zlx  阅读(319)  评论(0)    收藏  举报