单独一个目录,可能需要遍历实现。
总的可以用disk_free_space 函数和上面你的那个的差。

解决方案 »

  1.   

    如果是自己的机器,调用unix命令
      

  2.   

    给你一段代码,
    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;
    }
      

  3.   

    再给你一个更好的解决方法。
    $str = exec("du -sh $path,$return_var);
    echo $str;