A easy way to check the file size
Converts a string like "5 MB", or "400 KB" to the equivalent in Bytes.
function StringSizeToBytes($Size){ $Unit = strtolower($Size); $Unit = preg_replace('/[^a-z]/', '', $Unit); $Value = intval(preg_replace('/[^0-9]/', '', $Size)); $Units = array('b'=>0, 'kb'=>1, 'mb'=>2, 'gb'=>3, 'tb'=>4); $Exponent = isset($Units[$Unit]) ? $Units[$Unit] : 0; return ($Value * pow(1024, $Exponent)); }
Sorry folks, comments have been deactivated for now due to the large amount of spam.
Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!
Older comments:
None.