File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ export class NgxFileDropComponent implements OnDestroy {
235235 private traverseFileTree ( item : FileSystemEntry , path : string ) : void {
236236 if ( item . isFile ) {
237237 const toUpload : NgxFileDropEntry = new NgxFileDropEntry ( path , item ) ;
238- this . files . push ( toUpload ) ;
238+ this . addToQueue ( toUpload ) ;
239239
240240 } else {
241241 path = path + '/' ;
@@ -332,9 +332,28 @@ export class NgxFileDropComponent implements OnDestroy {
332332 }
333333
334334 private addToQueue ( item : NgxFileDropEntry ) : void {
335+ const isAcceptedExt = this . isAcceptedExtension ( this . accept , item . fileEntry . name ) ;
336+ if ( ! isAcceptedExt ) return ;
337+
335338 this . files . push ( item ) ;
336339 }
337340
341+ private getFileExtension ( fileName : string ) {
342+ const extension = fileName . split ( '.' ) . slice ( - 1 ) [ 0 ] ;
343+ return `.${ extension } ` ;
344+ }
345+
346+ private isAcceptedExtension ( acceptedExtensions : string , fileName : string ) {
347+ if ( acceptedExtensions === "*" ) {
348+ return true ;
349+ }
350+
351+ const fileExtension = this . getFileExtension ( fileName ) ;
352+
353+ const acceptedExtList = acceptedExtensions . split ( ',' ) ;
354+ return acceptedExtList . includes ( fileExtension ) ;
355+ }
356+
338357 private preventAndStop ( event : Event ) : void {
339358 event . stopPropagation ( ) ;
340359 event . preventDefault ( ) ;
You can’t perform that action at this time.
0 commit comments