Skip to content

Instantly share code, notes, and snippets.

@s2ar
Created June 21, 2016 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s2ar/225e5352c74d9b565fc32177af14a5b8 to your computer and use it in GitHub Desktop.
Save s2ar/225e5352c74d9b565fc32177af14a5b8 to your computer and use it in GitHub Desktop.
Максимальный размер загружаемого файла
<?php
function convertPHPSizeToBytes($sSize)
{
if ( is_numeric( $sSize) ) {
return $sSize;
}
$sSuffix = substr($sSize, -1);
$iValue = substr($sSize, 0, -1);
switch(strtoupper($sSuffix)){
case 'P':
$iValue *= 1024;
case 'T':
$iValue *= 1024;
case 'G':
$iValue *= 1024;
case 'M':
$iValue *= 1024;
case 'K':
$iValue *= 1024;
break;
}
return $iValue;
}
function getMaximumFileUploadSize()
{
return min(convertPHPSizeToBytes(ini_get('post_max_size')), convertPHPSizeToBytes(ini_get('upload_max_filesize')));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment