App: add upload_max_filesize config parameter to set upload_max_filesize & upload_max_filesize

This commit is contained in:
Benjamin Renard 2023-02-27 16:15:47 +01:00
parent d461b28b7d
commit c346252f55
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
3 changed files with 18 additions and 4 deletions

View file

@ -7,9 +7,13 @@ data_directory: "${root_directory_path}/data"
# Temporary files root directory
tmp_root_directory: "${data_directory}/tmp"
# Temporary uploading files directory
# Temporary uploading files directory (optional, default: PHP ini default)
upload_tmp_directory: ${tmp_root_directory}/uploading"
# Uploading file size limit (in bytes, example: 104857600 == 100Mb)
# (optional, default: PHP ini default)
upload_max_filesize: 104857600
# Main pagetitle
main_pagetitle: "Eesyphp"

View file

@ -7,9 +7,13 @@ data_directory: "${root_directory_path}/data"
# Temporary files root directory
tmp_root_directory: "${data_directory}/tmp"
# Temporary uploading files directory
# Temporary uploading files directory (optional, default: PHP ini default)
upload_tmp_directory: ${tmp_root_directory}/uploading"
# Uploading file size limit (in bytes, example: 104857600 == 100Mb)
# (optional, default: PHP ini default)
upload_max_filesize: 104857600
# Main pagetitle
main_pagetitle: "Eesyphp"

View file

@ -51,8 +51,14 @@ class App {
$sentry_span = new SentrySpan('app.init', 'Application initialization');
// Define upload_tmp_dir
if (is_string(self::get('upload_tmp_directory')))
ini_set('upload_tmp_dir', self::get('upload_tmp_directory'));
if (self::isset('upload_tmp_directory'))
ini_set('upload_tmp_dir', self::get('upload_tmp_directory', null, 'string'));
if (self::isset('upload_max_filesize')) {
ini_set('upload_max_filesize', self::get('upload_max_filesize', null, 'string'));
// post_max_size must be larger than upload_max_filesize
// See: https://www.php.net/manual/en/ini.core.php#ini.post-max-size
ini_set('post_max_size', strval(self::get('upload_max_filesize', null, 'int') * 1.1));
}
if (self :: get('log.enabled', true, 'bool'))
Log::init();