'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
];
- public $_uploadMaxSize;
-
/**
* Basic setup.
*/
public function preProcess() {
- $this->_uploadMaxSize = (int) ini_get('upload_max_filesize');
// check for post max size
CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE);
// This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but
$errors = [];
// validate max file size
- if ($fields['maxFileSize'] > $options->_uploadMaxSize) {
- $errors['maxFileSize'] = ts("Maximum file size cannot exceed Upload max size ('upload_max_filesize') as defined in PHP.ini.");
+ $iniBytes = CRM_Utils_Number::formatUnitSize(ini_get('upload_max_filesize'), FALSE);
+ $inputBytes = CRM_Utils_Number::formatUnitSize($fields['maxFileSize'] . 'M', FALSE);
+
+ if ($inputBytes > $iniBytes) {
+ $errors['maxFileSize'] = ts("Maximum file size cannot exceed limit defined in \"php.ini\" (\"upload_max_filesize=%1\") .", [
+ 1 => ini_get('upload_max_filesize'),
+ ]);
}
// validate recent items stack size