Created
October 20, 2016 08:18
-
-
Save lomboboo/afd1f9075b064e020454d50ab0bc1bcd to your computer and use it in GitHub Desktop.
function to return file size in GB MB KB bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function file_size2($url){ | |
$size = filesize($url); | |
if($size >= 1073741824){ | |
$fileSize = round($size/1024/1024/1024,1) . 'GB'; | |
}elseif($size >= 1048576){ | |
$fileSize = round($size/1024/1024,1) . 'MB'; | |
}elseif($size >= 1024){ | |
$fileSize = round($size/1024,1) . 'KB'; | |
}else{ | |
$fileSize = $size . ' bytes'; | |
} | |
return $fileSize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment