Index: lams_central/web/qb/importQuestionsXml.jsp =================================================================== diff -u -rf92b1383638a766c5d8496c6f607322dd2af8329 -r0559504eae34958a1b85105cedeff10e591a52cf --- lams_central/web/qb/importQuestionsXml.jsp (.../importQuestionsXml.jsp) (revision f92b1383638a766c5d8496c6f607322dd2af8329) +++ lams_central/web/qb/importQuestionsXml.jsp (.../importQuestionsXml.jsp) (revision 0559504eae34958a1b85105cedeff10e591a52cf) @@ -50,24 +50,35 @@ UPLOAD_FILE_MAX_SIZE = ''; function initFileUpload(tmpFileUploadId, language) { - var uppyProperties = { - // upload immediately - autoProceed: true, - allowMultipleUploads: true, - debug: false, - restrictions: { - // taken from LAMS configuration - maxFileSize: +UPLOAD_FILE_MAX_SIZE, - maxNumberOfFiles: 1, - allowedFileTypes : ['.xml'] - }, - meta: { - // all uploaded files go to this subdir in LAMS tmp dir - // its format is: upload__ - 'tmpFileUploadId' : tmpFileUploadId, - 'largeFilesAllowed' : true - } - }; + var allowedFileTypes = ['.xml'], + uppyProperties = { + // upload immediately + autoProceed: true, + allowMultipleUploads: true, + debug: false, + restrictions: { + // taken from LAMS configuration + maxFileSize: +UPLOAD_FILE_MAX_SIZE, + maxNumberOfFiles: 1, + allowedFileTypes : allowedFileTypes + }, + meta: { + // all uploaded files go to this subdir in LAMS tmp dir + // its format is: upload__ + 'tmpFileUploadId' : tmpFileUploadId, + 'largeFilesAllowed' : true + }, + onBeforeFileAdded: function(currentFile, files) { + var name = currentFile.data.name, + extensionIndex = name.lastIndexOf('.'), + valid = allowedFileTypes.includes(name.substring(extensionIndex).trim()); + if (!valid) { + uppy.info('', 'error', 10000); + } + + return valid; + } + }; switch(language) { case 'es' : uppyProperties.locale = Uppy.locales.es_ES; break; @@ -92,6 +103,10 @@ height: 120, width: '100%' }); + + uppy.use(Uppy.Informer, { + target: '#image-upload-area' + }); uppy.use(Uppy.StatusBar, { target: '#image-upload-area',