<?php
require "byte_converter.class.php";
//EXAMPLE AUTO CONVERT
if($_SERVER["REQUEST_METHOD"] == "POST") {
try{
$byte = new byte_converter;
$byte->set_limit("tb"); //show types up to tera byte
$result = $byte->auto($_POST['integer'],$_POST['type']);
}catch (Exception $e) {echo $e;}
}
//1048576000
/* EXAMPLE MANUAL CONVERT
try{
$byte = new byte_converter;
$total = $byte->convert("128849018880","b","kb");
echo $total;
}catch(Exception $e) {echo $e;} */
?>
<html>
<head>
<title>Byte Converter</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<form action="" id="convert" method="post">
<input type="text" size="30" name="integer" />
<select name="type" size="1">
<option value="b">B</option>
<option value="kb" selected>KB</option>
<option value="mb">MB</option>
<option value="gb">GB</option>
<option value="tb">TB</option>
<option value="pb">PB</option>
<option value="eb">EB</option>
<option value="zb">ZB</option>
<option value="yb">YB</option>
</select>
<input type="submit" name="auto" value="Auto Convert" />
<font size="2">* Enter a value forexample 1024 KB (and choose KB) or 3000 MB (and choose MB)</font>
</form>
<?php print_r($result); ?>
</body>
</html>
|