$upload_max_filesize        = return_bytes(ini_get('upload_max_filesize'));
$post_max_size              = return_bytes(ini_get('post_max_size'));

if ( $upload_max_filesize > $post_max_size ) {
    $max = ini_get('post_max_size');
} else {
    $max = ini_get('upload_max_filesize');
}

$h = "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
<html>
<head>
<meta http-equiv='Content-type' content='text/html;charset=UTF-8'>
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\" />
<title>nuBuilder</title>
<link rel=\"stylesheet\" href=\"jquery/jquery-ui.css\" />
<script src=\"jquery/jquery-1.8.3.js\" type='text/javascript'></script>
<script src=\"jquery/jquery-ui.js\" type='text/javascript'></script>
<script>
function switchToProgress() {
	parent.toggleShow('hidden');
    var contents = '<br><br><p><i>Please wait for file to upload </i></p><img src=\"ajax-loader.gif\">';
	$('#nuFileFormWrapper').css('visibility', 'hidden');
	$('#nuFileHeader').html(contents);
	$(parent.document).find('#nuButton0').css('visibility', 'hidden');
    $(parent.document).find('#nuButton1').css('visibility', 'hidden');      
}
</script>
<style>
body{margin: 0;font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;font-size: 13px;line-height: 18px;color: #202020;background-color: ##f4f4f4;}
</style>
<body>
<div id='nuFileHeader'>
	<br>
	<p><i>Please select a file to upload, the size limit of your server is $max </i></p>
</div>	
<div id='nuFileFormWrapper'>
	<form id='nuFileForm' enctype='multipart/form-data' action='nuupload.php' method='POST'>
    	<input name='userfile' type='file' onchange='this.form.submit(); switchToProgress();' />
	</form>
</div>
</body>
</html> 
";
echo $h;

function return_bytes($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;
}