Wednesday, June 30, 2010

maximum upload size in php


<?php
function max_upload_size()
{
    preg_match('/^([0-9]+)([PTGMK]?)$/i'strtoupperini_get('post_max_size') ), $p );
    preg_match('/^([0-9]+)([PTGMK]?)$/i'strtoupperini_get('upload_max_filesize') ), $u );
    $arr array('P'=>50,'T'=>40,'G'=>30,'M'=>20,'K'=>10);
    return min(  $p[1] * pow(2,$arr[$p[2]]), $u[1] * pow(2,$arr[$u[2]]) )/(1024*1024)."MB";
}
?>

No comments: