I need to round up sizes of file uploaded and determine what size format whether it’s kb,mb or gb.
Detail:
While users upload picture, picture attributes are fetched via the global $_FILES. If for example, a user upload a picture of 29.6kb, and I decide to check the size of the picture uploaded, the $_FILES[size] array echo the size as 30358.
And what I’m trying to do with the value gotten from the $_FILES[size] is to round up the picture size from 30758 to 31 and then concatenate the file size format (kb, mb or gb) to it and echo it as 31kb.
I really hope to get help with this…Thanks!
Laravel uses this helper function:
*Source: https://github.com/laravel/laravel/blob/master/laravel/helpers.php
I haven’t seen a more elegant way for doing this yet.