aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2019-09-22 13:02:24 +0200
committerMarc Alexander <admin@m-a-styles.de>2019-09-22 13:02:24 +0200
commit7e8c6d8c0d62c5b472e95c2adf8592e0ca735282 (patch)
tree8c1f5417edcbe267ddcf9cf07d860e3647f78885 /phpBB/assets
parentMerge branch '3.2.x' into 3.3.x (diff)
parentMerge pull request #5664 from mrgoldy/ticket/16076 (diff)
downloadphpbb-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.js38
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');
/**