Last active
June 20, 2017 12:14
-
-
Save harini-ua/0bce4bd77aae62c567ff63ccbbcdd2d3 to your computer and use it in GitHub Desktop.
Laravel Helper Pack
This file contains hidden or 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
<?php | |
/** | |
* Return sizes readable by humans | |
*/ | |
function human_filesize($bytes, $decimals = 2) | |
{ | |
$size = ['B', 'kB', 'MB', 'GB', 'TB', 'PB']; | |
$factor = floor((strlen($bytes) - 1) / 3); | |
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . | |
@$size[$factor]; | |
} | |
/** | |
* Is the mime type an image | |
*/ | |
function is_image($mimeType) | |
{ | |
return starts_with($mimeType, 'image/'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment