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];
}``````
1
Contributor
0
Replies
3
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.