From 738b6ae5832fb7c2992ec0dc52399e4dbf3d096d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 13 Feb 2016 19:24:36 -0500 Subject: Add file drag and drop and asynchronous upload --- app/Helper/Text.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app/Helper/Text.php') diff --git a/app/Helper/Text.php b/app/Helper/Text.php index 59bfd997..83f1e3f9 100644 --- a/app/Helper/Text.php +++ b/app/Helper/Text.php @@ -42,6 +42,29 @@ class Text extends Base return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($base)]; } + /** + * Get the number of bytes from PHP size + * + * @param integer $val PHP size (example: 2M) + * @return integer + */ + public function phpToBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + + switch ($last) { + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + + return $val; + } + /** * Return true if needle is contained in the haystack * -- cgit v1.2.3