From 158918b44d26b96e32a9021826937ce672522e25 Mon Sep 17 00:00:00 2001 From: Maik Diepenbroek Date: Mon, 19 Feb 2018 07:59:40 +0100 Subject: [PATCH] This commit addresses the problem of not being able to upload the same file twice. Since the value property of the file component does not change, the change event does not fire preventing the user from starting the upload. By adding a click handler on the input, the value is set to an empty string, causing the 'bug' to not happen. --- package-lock.json | 2 +- src/ngx-uploader/directives/ng-file-select.directive.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 174fea83..0a96feda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ngx-uploader", - "version": "4.2.1", + "version": "4.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/ngx-uploader/directives/ng-file-select.directive.ts b/src/ngx-uploader/directives/ng-file-select.directive.ts index 33b08965..a7c28fdc 100644 --- a/src/ngx-uploader/directives/ng-file-select.directive.ts +++ b/src/ngx-uploader/directives/ng-file-select.directive.ts @@ -26,6 +26,8 @@ export class NgFileSelectDirective implements OnInit, OnDestroy { this.upload = new NgUploaderService(concurrency, allowedContentTypes); this.el = this.elementRef.nativeElement; + + this.el.addEventListener('click', this.clickListener, false); this.el.addEventListener('change', this.fileListener, false); this._sub.push( @@ -46,6 +48,12 @@ export class NgFileSelectDirective implements OnInit, OnDestroy { } } + clickListener = () => { + if(this.el.value) { + this.el.value = ''; + } + } + fileListener = () => { if (this.el.files) { this.upload.handleFiles(this.el.files);