I was digging through my old codes to get this, still could not find. Hence when I wrote it, just made a note here such that later it wont be difficult to find atleast for me.
Format filesize, php filesize human readable
function formatSize($size){ $units = array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size > 1024; $i++) { $size /= 1024; } return round($size, 2).$units[$i]; }