Project

General

Profile

Feature #20202 » 10717_add_fileupload_function.patch

Administrator Admin, 2009-03-18 12:04

View differences:

t3lib/class.t3lib_div.php (Arbeitskopie)
}
/**
* Returns the maximum upload size for a file that is allowed. Measured in KB.
* This might be handy to find out the real upload limit that is possible for this
* TYPO3 installation. The first parameter can be used to set something that overrides
* the maxFileSize, usually for the TCA values.
*
* @param int the number of Kilobytes (!) that should be used as the initial Limit, otherwise $TYPO3_CONF_VARS['BE']['maxFileSize'] will be used
* @return int the maximum size of uploads that are allowed
*/
public static function getMaxUploadFileSize($localLimit = 0) {
// don't allow more than the global max file size at all
$t3Limit = intval($localLimit > 0 ? $localLimit : $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
// as TYPO3 is handling the file size in KB, multiply by 1024 to get bytes
$t3Limit = $t3Limit*1024;
// check for PHP restrictions of the maximum size of one of the $_FILES
$phpUploadLimit = ini_get('upload_max_filesize');
if (stripos($phpUploadLimit, 'G')) {
$phpUploadLimit = intval($phpUploadLimit)*1024*1024*1024;
} else if (stripos($phpUploadLimit, 'M')) {
$phpUploadLimit = intval($phpUploadLimit)*1024*1024;
} else if (stripos($phpUploadLimit, 'K')) {
$phpUploadLimit = intval($phpUploadLimit)*1024;
} else {
$phpUploadLimit = intval($phpUploadLimit);
}
// check for PHP restrictions of the maximum $_POST size
$phpPostLimit = ini_get('post_max_size');
if (stripos($phpPostLimit, 'G')) {
$phpPostLimit = intval($phpPostLimit)*1024*1024*1024;
} else if (stripos($phpPostLimit, 'M')) {
$phpPostLimit = intval($phpPostLimit)*1024*1024;
} else if (stripos($phpPostLimit, 'K')) {
$phpPostLimit = intval($phpPostLimit)*1024;
} else {
$phpPostLimit = intval($phpPostLimit);
}
// if the total amount of post data is smaller (!) than the upload_max_filesize directive,
// then this is the real limit in PHP
$phpUploadLimit = ($phpPostLimit < $phpUploadLimit ? $phpPostLimit : $phpUploadLimit);
// is the allowed PHP limit (upload_max_filesize) lower than the TYPO3 limit?, also: revert back to KB
return round($phpUploadLimit < $t3Limit ? $phpUploadLimit : $t3Limit)/1024;
}
t3lib/class.t3lib_extfilefunc.php (Arbeitskopie)
$this->unzipPath = $GLOBALS['TYPO3_CONF_VARS']['BE']['unzip_path'];
$maxFileSize = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize']);
if ($maxFileSize>0) {
if ($maxFileSize > 0) {
$this->maxCopyFileSize = $maxFileSize;
$this->maxMoveFileSize = $maxFileSize;
$this->maxUploadFileSize = $maxFileSize;
}
$this->maxUploadFileSize = t3lib_div::getMaxUploadFileSize();
// Initializing file processing commands:
$this->fileCmdMap = $fileCmds;
(1-1/2)