http://search.csdn.net/Expert/topic/2383/2383886.xml?temp=.9958612
选遍历目录,得到每个文件的大小。
用filetype()来判断是文件(file)还是目录(dir)
用filesize()来得到文件大小。
选遍历目录,得到每个文件的大小。
用filetype()来判断是文件(file)还是目录(dir)
用filesize()来得到文件大小。
解决方案 »
- mysql安装
- //php中的问题真是千奇百怪啊,具然碰到这个问题,请大家一起看一下.
- 请问怎样将字段值合并
- mysql安装问题.can't create windows service for mysql.
- php程序设计
- 采用MVC方式编程时,关于Controller的使用方法
- 请教一个思路,现在想不通了
- 散点分,谈谈最近学习心得体会
- 这个正则为什么匹配错误?
- PHP PDO FETCH_ORI_LAST这个我什么不起作用呢
- mysql疑问:将表a中所有tid=5的数据插入到表b(两表结构相同),怎样写mysql语句?
- 请教:php+mysql+apache+phpMyAdmin的怪问题。
@$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;
}//END tunction dirsizefunction sizecount($filesize) { //计算出所有文件大小
if($filesize >= 1073741824) {
$filesize = round($filesize / 1073741824 * 100) / 100 . ' G';
} elseif($filesize >= 1048576) {
$filesize = round($filesize / 1048576 * 100) / 100 . ' M';
} elseif($filesize >= 1024) {
$filesize = round($filesize / 1024 * 100) / 100 . ' K';
} else {
$filesize = $filesize . ' bytes';
}
return $filesize;
要的时间调用:
$attachsize = dirsize("../SaveHtm");
$attachsize = $attachsize ? sizecount($attachsize) : "大小未知";
最后echo $attachsize得到的就是你指定目录下所有文件及子文件夹下的所有文件的总大小.
在 return $filesize;的后面要加上
}//END tunction sizecount
才正确.