From 9f897e1e4d97eb96c2882887fa4a7521e1e43acf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 30 Jun 2020 11:26:46 +0200 Subject: [PATCH] Add support for acceptable types to WoltLabSuite/Core/Upload see #3414 --- wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js index 4b0254c85a..0b03a829f9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js @@ -44,6 +44,8 @@ define(['AjaxRequest', 'Core', 'Dom/ChangeListener', 'Language', 'Dom/Util', 'Do action: 'upload', // is true if multiple files can be uploaded at once multiple: false, + // array of accepted file types, null if any file type is allowed + acceptableFiles: null, // name if the upload field name: '__files[]', // is true if every file from a multi-file selection is uploaded in its own request @@ -89,6 +91,9 @@ define(['AjaxRequest', 'Core', 'Dom/ChangeListener', 'Language', 'Dom/Util', 'Do if (this._options.multiple) { elAttr(this._fileUpload, 'multiple', 'true'); } + if (this._options.acceptableFiles !== null) { + elAttr(this._fileUpload, 'accept', this._options.acceptableFiles.join(',')); + } this._fileUpload.addEventListener('change', this._upload.bind(this)); this._button = elCreate('p'); -- 2.20.1