File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
Backend/view/adminhtml/web/js
Ui/view/base/web/js/form/element Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,16 @@ define([
7474 $ . mage . __ ( 'We could not detect a size.' ) :
7575 byteConvert ( currentFile . size ) ;
7676
77+ // check if file is allowed to upload and resize
78+ allowedResize = $ . inArray ( currentFile . extension , allowedExt ) !== - 1 ;
79+
80+ if ( ! allowedResize ) {
81+ fileUploader . aggregateError ( currentFile . name ,
82+ $ . mage . __ ( 'Disallowed file type.' ) ) ;
83+ fileUploader . onLoadingStop ( ) ;
84+ return false ;
85+ }
86+
7787 fileId = Math . random ( ) . toString ( 33 ) . substr ( 2 , 18 ) ;
7888
7989 tmpl = progressTmpl ( {
@@ -91,9 +101,6 @@ define([
91101 tempFileId : fileId
92102 } ;
93103
94- // check if resize allowed for file extension
95- allowedResize = $ . inArray ( currentFile . extension , allowedExt ) !== - 1 ;
96-
97104 $ ( tmpl ) . appendTo ( self . element ) ;
98105 return modifiedFile ;
99106 } ,
Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ define([
6868 if ( fileInput !== undefined ) {
6969 let targetElement = $ ( fileInput ) . closest ( '.file-uploader-area' ) [ 0 ] ,
7070 dropTargetElement = $ ( fileInput ) . closest ( this . dropZone ) [ 0 ] ,
71- fileObj = [ ] ,
7271 formKey = window . FORM_KEY !== undefined ? window . FORM_KEY : $ . cookie ( 'form_key' ) ,
7372 fileInputName = this . fileInputName ,
7473 arrayFromObj = Array . from ,
@@ -105,12 +104,8 @@ define([
105104 }
106105
107106 if ( ! allowed . passed ) {
108- fileObj . push ( currentFile ) ;
109107 this . aggregateError ( file . name , allowed . message ) ;
110-
111- if ( this . aggregatedErrors . length === fileObj . length ) {
112- this . uploaderConfig . stop ( ) ;
113- }
108+ this . uploaderConfig . stop ( ) ;
114109 return false ;
115110 }
116111
You can’t perform that action at this time.
0 commit comments