/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function getFileSize($bytes) { if ($bytes >= 1099511627776) { $suffix = "TB"; } elseif ($bytes >= 1073741824) { $suffix = "GB"; } elseif ($bytes >= 1048576) { $suffix = "MB"; } elseif ($bytes >= 1024) { $suffix = "KB"; } else { $return = $bytes; $suffix = "Bytes"; } if ($return == 1) { $return .= " " . $suffix; } else { $return .= " " . $suffix . " "; } return $return; }