PHP get actual maximum upload size

前端 未结 6 473
Happy的楠姐
Happy的楠姐 2020-12-04 16:38

When using

ini_get(\"upload_max_filesize\");

it actually gives you the string specified in the php.ini file.

It is not good to use

6条回答
  •  粉色の甜心
    2020-12-04 17:07

    This is what I use:

    function asBytes($ini_v) {
       $ini_v = trim($ini_v);
       $s = [ 'g'=> 1<<30, 'm' => 1<<20, 'k' => 1<<10 ];
       return intval($ini_v) * ($s[strtolower(substr($ini_v,-1))] ?: 1);
    }
    

提交回复
热议问题