Possible Duplicate:
PHP – get the size of a directory
I have 5 files in a directory and it shows file size = 4096 but when i delete 4 files and there is only 1 file left, it still shows the same size. that is how i am getting the file size
echo filesize("user_files/".$uid."/".$rs['DirectoryName']);
filesize
applied to the directory doesn't give the size of its contents. It returns the size of the filesystem node, which, in your case, takes 4kb. This size depends on the amount of the files in the directory.
To get the actual size of contents - you need to get the size of each file and summarize it.
You can get your Total folder size and it Sub directory like this
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS));
$size = 0;
foreach ( $dir as $file ) {
$size += $file->getSize();
}
var_dump($size);
Also note that
Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB.