diff --git a/src/ngx-uploader/classes/ngx-uploader.class.ts b/src/ngx-uploader/classes/ngx-uploader.class.ts index 1c012c76..bc602cce 100644 --- a/src/ngx-uploader/classes/ngx-uploader.class.ts +++ b/src/ngx-uploader/classes/ngx-uploader.class.ts @@ -37,17 +37,16 @@ export class NgUploaderService { } handleFiles(incomingFiles: FileList): void { - let allowedIncomingFiles: File[] = []; - - for (let i = 0; i < incomingFiles.length; i++) { - let checkFile = incomingFiles[i]; + const allowedIncomingFiles: File[] = [].reduce.call(incomingFiles, (acc: File[], checkFile: File, i: number) => { if (this.isContentTypeAllowed(checkFile.type)) { - allowedIncomingFiles.push(checkFile); + acc = acc.concat(checkFile); } else { const rejectedFile: UploadFile = this.makeUploadFile(checkFile, i); this.serviceEvents.emit({ type: 'rejected', file: rejectedFile }); } - } + + return acc; + }, []); this.queue.push(...[].map.call(allowedIncomingFiles, (file: File, i: number) => { const uploadFile: UploadFile = this.makeUploadFile(file, i); diff --git a/src/ngx-uploader/module/ngx-uploader.module.ts b/src/ngx-uploader/module/ngx-uploader.module.ts index 0f58ee1a..9f9ceb6d 100644 --- a/src/ngx-uploader/module/ngx-uploader.module.ts +++ b/src/ngx-uploader/module/ngx-uploader.module.ts @@ -13,4 +13,3 @@ import { NgFileSelectDirective } from '../directives/ng-file-select.directive'; ] }) export class NgUploaderModule {} -