Beispiel #1
0
 /**
  * Maximum upload size as limited by PHP
  * Used with permission from Moodle (http://moodle.org) by Martin Dougiamas
  *
  * this section generates $max_upload_size in bytes
  */
 function checkUploadSize()
 {
     if (!($filesize = ini_get('upload_max_filesize'))) {
         $filesize = "5M";
     }
     if ($postsize = ini_get('post_max_size')) {
         $this->set('max_upload_size', min(PMA_get_real_size($filesize), PMA_get_real_size($postsize)));
     } else {
         $this->set('max_upload_size', PMA_get_real_size($filesize));
     }
 }
 public function testGigabyte()
 {
     $this->assertEquals(12 * 1024 * 1024 * 1024, PMA_get_real_size('12gb'));
 }
Beispiel #3
0
    //1024 * 1024 * 1024;
    $scan['mb'] = 1048576;
    $scan['m'] = 1048576;
    $scan['kb'] = 1024;
    $scan['k'] = 1024;
    $scan['b'] = 1;
    foreach ($scan as $unit => $factor) {
        if (strlen($size) > strlen($unit) && strtolower(substr($size, strlen($size) - strlen($unit))) == $unit) {
            return substr($size, 0, strlen($size) - strlen($unit)) * $factor;
        }
    }
    return $size;
}
// end function PMA_get_real_size()
$upload_max_filesize = PMA_get_real_size(ini_get('upload_max_filesize'));
$post_max_size = PMA_get_real_size(ini_get('post_max_size'));
$min_upload_size = $upload_max_filesize > $post_max_size ? $post_max_size : $upload_max_filesize;
$max_upload_filesize = $min_upload_size / 1024 / 1024 . ' MB';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="swfupload/swfupload.js"></script>
<script type="text/javascript" src="js/swfupload.swfobject.js"></script>
<script type="text/javascript" src="js/swfupload.queue.js"></script>
<script type="text/javascript" src="js/fileprogress.js"></script>
<script type="text/javascript" src="js/handlers.js"></script>
<script type="text/javascript">
 public function testUnspecified()
 {
     $this->assertEquals(1024, PMA_get_real_size('1024'));
 }