diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts index 413b76e58d..1545851d76 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts @@ -128,7 +128,7 @@ export class UploadButtonComponent implements OnInit, OnChanges { * @param {File[]} files - files dropped in the drag area. */ onFilesAdded($event: any): void { - let files = $event.currentTarget.files; + let files: File[] = this.getFiles($event.currentTarget.files); if (this.hasPermission) { this.uploadFiles(this.currentFolderPath, files); @@ -145,7 +145,7 @@ export class UploadButtonComponent implements OnInit, OnChanges { * @param {File[]} files - files of a folder dropped in the drag area. */ onDirectoryAdded($event: any): void { - let files = $event.currentTarget.files; + let files: File[] = this.getFiles($event.currentTarget.files); if (this.hasPermission) { let hashMapDir = this.convertIntoHashMap(files); @@ -211,6 +211,18 @@ export class UploadButtonComponent implements OnInit, OnChanges { return directoryMap; } + private getFiles(fileList: FileList): File[] { + const result: File[] = []; + + if (fileList && fileList.length > 0) { + for (let i = 0; i < fileList.length; i++) { + result.push(fileList[i]); + } + } + + return result; + } + /** * Split the directory path given as input and cut the last directory name * @param directory