diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-09-22 13:02:24 +0200 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-09-22 13:02:24 +0200 |
commit | 7e8c6d8c0d62c5b472e95c2adf8592e0ca735282 (patch) | |
tree | 8c1f5417edcbe267ddcf9cf07d860e3647f78885 /phpBB/assets | |
parent | Merge branch '3.2.x' into 3.3.x (diff) | |
parent | Merge pull request #5664 from mrgoldy/ticket/16076 (diff) | |
download | phpbb-7e8c6d8c0d62c5b472e95c2adf8592e0ca735282.tar.gz phpbb-7e8c6d8c0d62c5b472e95c2adf8592e0ca735282.tar.bz2 phpbb-7e8c6d8c0d62c5b472e95c2adf8592e0ca735282.zip |
Merge branch '3.2.x' into 3.3.x
Diffstat (limited to 'phpBB/assets')
-rw-r--r-- | phpBB/assets/javascript/plupload.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/phpBB/assets/javascript/plupload.js b/phpBB/assets/javascript/plupload.js index 5e8db8b035..8c52aae819 100644 --- a/phpBB/assets/javascript/plupload.js +++ b/phpBB/assets/javascript/plupload.js @@ -463,6 +463,44 @@ phpbb.plupload.fileError = function(file, error) { phpbb.plupload.uploader = new plupload.Uploader(phpbb.plupload.config); phpbb.plupload.initialize(); +/** + * Add a file filter to check for max file sizes per mime type. + */ +plupload.addFileFilter('mime_types_max_file_size', function(types, file, callback) { + if (file.size !== 'undefined') { + $(types).each(function(i, type) { + let extensions = [], + extsArray = type.extensions.split(','); + + $(extsArray).each(function(i, extension) { + /^\s*\*\s*$/.test(extension) ? extensions.push("\\.*") : extensions.push("\\." + extension.replace(new RegExp("[" + "/^$.*+?|()[]{}\\".replace(/./g, "\\$&") + "]", "g"), "\\$&")); + }); + + let regex = new RegExp("(" + extensions.join("|") + ")$", "i"); + + if (regex.test(file.name)) { + if (type.max_file_size !== 'undefined' && type.max_file_size) { + if (file.size > type.max_file_size) { + phpbb.plupload.uploader.trigger('Error', { + code: plupload.FILE_SIZE_ERROR, + message: plupload.translate('File size error.'), + file: file + }); + + callback(false); + } else { + callback(true); + } + } else { + callback(true); + } + + return false; + } + }); + } +}); + var $fileList = $('#file-list'); /** |