<?php
/****************************************************************************
* Usage is simple:
* $foo = get_size('/directory/another/whatsize/');
* also can be used like $bar = get_size('/directory/filesize.jpg');
* if you really wanted to.
*****************************************************************************/
function get_size
($path)
{
if(!
is_dir($path))
{
return filesize($path);
}
$dir =
opendir($path);
while($file =
readdir($dir))
{
if(is_file($path.
"/".
$file))
{
$size+=
filesize($path.
"/".
$file);
}
if(is_dir($path.
"/".
$file) &&
$file!=
"." &&
$file !=
"..")
{
$size +=get_size
($path.
"/".
$file);
}
}
return $size;
}
?>