Convert size in *KB, *MB, *GB ....


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function file_size($size)
  2. {
  3. $filesizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
  4. return $size ? round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $filesizename[$i] : '0 Bytes';
  5. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.