Skip to content

Instantly share code, notes, and snippets.

@lomboboo
Created October 20, 2016 08:18
Show Gist options
  • Save lomboboo/afd1f9075b064e020454d50ab0bc1bcd to your computer and use it in GitHub Desktop.
Save lomboboo/afd1f9075b064e020454d50ab0bc1bcd to your computer and use it in GitHub Desktop.
function to return file size in GB MB KB bytes
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