From: Tim Düsterhus Date: Tue, 30 Jun 2020 09:26:46 +0000 (+0200) Subject: Add support for acceptable types to WoltLabSuite/Core/Upload X-Git-Tag: 5.3.0_Alpha_1~179^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9f897e1e4d97eb96c2882887fa4a7521e1e43acf;p=GitHub%2FWoltLab%2FWCF.git Add support for acceptable types to WoltLabSuite/Core/Upload see #3414 --- 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');