Wednesday, July 14, 2010
What is the difference between KB, MB and GB in terms of Computer Memory or PHP class to calculate the size of a folder or directory
Jan
What is the difference between KB, MB and GB in terms of Computer Memory
1.00 KB = 1,024 bytes that means 4.00 KB (4,096 bytes)
1 MB = 1048576 bytes
1 GB = 1073741824 bytes
KB, MB and GB are units of memory in computer. KB stands for kilobytes which mean 1024 bytes. MB means megabyte which means 1024 KB. And GB is gigabytes which mean 1024 MB.
More useful explaination
How Many KB In A MB?
1024 KB
Which Is Bigger A MB Or KB?
Megabyte = 1024 kilobytes
How Many KB In 1 GB?
Millions
How Many Kb Equal 1 GB?
One million
What Is 256 Mb Divided By 292 Kb?
256 Mb/(292 Kb*(1 Mb/(1024 Kb))) = 256/(292/1024) ≈ 856.2
I wanted to calculate the size of Folder/Directory using PHP so i found a class that will give me the output(the size of folder in terms of bytes )
Here is PHP class to calculate the size of a folder or directory
$path = "uploads/user_videos";
echo "Folder $path = ".filesize_r($path)." bytes";
function filesize_r($path){
if(!file_exists($path)) return 0;
if(is_file($path)) return filesize($path);
$ret = 0;
foreach(glob($path."/*") as $fn)
$ret += filesize_r($fn);
return $ret;
}
?>
No Comments Yet
Related Posts
Post a Comment
Comment please let me know your opinion