Upload - Improve max filesize in bytes from ini - refs BT#19380

pull/4174/head
Christian 4 years ago
parent 780e7614d6
commit 1c91e11758
  1. 29
      main/inc/lib/fileUpload.lib.php
  2. 2
      main/inc/lib/formvalidator/Element/BigUpload.php
  3. 3
      main/inc/lib/javascript/bigupload/inc/bigUpload.php

@ -2177,3 +2177,32 @@ function add_all_documents_in_folder_to_database(
}
}
}
/**
* Get the uploax max filesize from ini php in bytes.
*
* @return int
*/
function getIniMaxFileSizeInBytes()
{
$maxSize = 0;
if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) {
// see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes
switch (strtoupper($matches['2'])) {
case 'G':
$maxSize = $matches['1'] * 1073741824;
break;
case 'M':
$maxSize = $matches['1'] * 1048576;
break;
case 'K':
$maxSize = $matches['1'] * 1024;
break;
default:
$maxSize = $matches['1'];
}
}
$maxSize = (int) $maxSize;
return $maxSize;
}

@ -25,7 +25,7 @@ class BigUpload extends HTML_QuickForm_file
{
$origin = $this->getAttribute('data-origin');
$id = $this->getAttribute('id');
$maxSize = ini_get('upload_max_filesize');
$maxSize = getIniMaxFileSizeInBytes();
$html = parent::toHtml();
$html .= '<div id="'.$id.'-bigUploadProgressBarContainer">
<div id="'.$id.'-bigUploadProgressBarFilled"></div>

@ -18,7 +18,6 @@ class BigUpload
/**
* Max allowed filesize. This is for unsupported browsers and
* as an additional security check in case someone bypasses the js filesize check.
*
*/
private $maxSize;
@ -51,7 +50,7 @@ class BigUpload
$tempDirectory = api_get_path(SYS_ARCHIVE_PATH);
$this->setTempDirectory($tempDirectory);
$this->setMainDirectory(self::MAIN_DIRECTORY);
$this->maxSize = ini_get('upload_max_filesize');
$this->maxSize = getIniMaxFileSizeInBytes();
}
/**

Loading…
Cancel
Save