Hello,
I noticed that when selecting a file, then I remove it, then I try to select the same file, I am not able to do it.
In my case I am using the Single file select. My app is Angular 4.
Any idea how to change this behavior?
Thanks
Hello,
I noticed that when selecting a file, then I remove it, then I try to select the same file, I am not able to do it.
In my case I am using the Single file select. My app is Angular 4.
Any idea how to change this behavior?
Thanks
I am experiencing the same type of issue. Selecting a file uploaded during a single control initialization does not seem to work. One can select other files, but any file uploaded can't be added again until the component is reinitialized.
I am experiencing the same type of issue. Selecting a file uploaded during a single control initialization does not seem to work. One can select other files, but any file uploaded can't be added again until the component is reinitialized.
This behavior can be reproduced on the test webpage for the library http://valor-software.com/ng2-file-upload/, just select the same file two times in a row during an upload operation. Even after removing the file from the queue the file does not get added and the "Upload All" button remains disabled.
This behavior can be reproduced on the test webpage for the library http://valor-software.com/ng2-file-upload/, just select the same file two times in a row during an upload operation. Even after removing the file from the queue the file does not get added and the "Upload All" button remains disabled.
In my own experience, this is the typical behavior of an HTML input tag. I've seen this issue on other websites that don't make use of ng2-file-upload. The input tag holds the previous value, and only kicks off an upload when that value changes. Selecting the same value again doesn't upload the file a second time. Here's my workaround:
In my own experience, this is the typical behavior of an HTML input tag. I've seen this issue on other websites that don't make use of ng2-file-upload. The input tag holds the previous value, and only kicks off an upload when that value changes. Selecting the same value again doesn't upload the file a second time. Here's my workaround:
```typescript
@ViewChild('fileInput') fileInput: any;
...
uploadFile() {
this.uploader.uploadAll();
this.fileInput.nativeElement.value = '';
}
```
```html
<input #fileInput id="file" type="file" ng2FileSelect [uploader]="uploader" (change)="uploadFile()"/>
```
@benjcallaghan It works for me! But I write it code in the upload success callback function, like this.
uploader.onSuccessItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
... // Some of your code
this.uploaderRef.nativeElement.value = '';
};
@benjcallaghan It works for me! But I write it code in the upload success callback function, like this.
```
uploader.onSuccessItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
... // Some of your code
this.uploaderRef.nativeElement.value = '';
};
```
This is more related to the input tag, but if you want to add some functionality to ng2-file-upload to natively handle this, a pull request would be more than welcome 😉
This is more related to the input tag, but if you want to add some functionality to ng2-file-upload to natively handle this, a pull request would be more than welcome 😉
public onChange($event: any): void {
let target = $event.target || $event.srcElement;
this.fileUploadService.addToQueue(target.files);
target.value = '';
}
WORK FOR ME
public onChange($event: any): void {
let target = $event.target || $event.srcElement;
this.fileUploadService.addToQueue(target.files);
target.value = '';
}
WORK FOR ME
you need to empty the input file value after upload
here the code worked for me HTML: <input type="file" name="myfile" #activeFrameinputFile ng2FileSelect [uploader]="frameUploader" (change)="frameUploader.uploadAll()" />
component import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
you need to empty the input file value after upload
here the code worked for me
**HTML:**
` <input type="file" name="myfile" #activeFrameinputFile ng2FileSelect [uploader]="frameUploader" (change)="frameUploader.uploadAll()" />`
**component**
`import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';`
`@ViewChild('activeFrameinputFile') InputFrameVariable: ElementRef;`
` this.frameUploader.onSuccessItem = (item, response, status, headers) => {`
`this.InputFrameVariable.nativeElement.value = '';`
` };`
this will definitely works
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hello,
I noticed that when selecting a file, then I remove it, then I try to select the same file, I am not able to do it.
In my case I am using the Single file select. My app is Angular 4.
Any idea how to change this behavior?
Thanks
I am experiencing the same type of issue. Selecting a file uploaded during a single control initialization does not seem to work. One can select other files, but any file uploaded can't be added again until the component is reinitialized.
This behavior can be reproduced on the test webpage for the library http://valor-software.com/ng2-file-upload/, just select the same file two times in a row during an upload operation. Even after removing the file from the queue the file does not get added and the "Upload All" button remains disabled.
In my own experience, this is the typical behavior of an HTML input tag. I've seen this issue on other websites that don't make use of ng2-file-upload. The input tag holds the previous value, and only kicks off an upload when that value changes. Selecting the same value again doesn't upload the file a second time. Here's my workaround:
@benjcallaghan It works for me! But I write it code in the upload success callback function, like this.
This is more related to the input tag, but if you want to add some functionality to ng2-file-upload to natively handle this, a pull request would be more than welcome 😉
I use this,
Because success and failure will be working
this.uploader.onCompleteAll = () => { this.fileInput.nativeElement.value = ''; }public onChange($event: any): void {
let target = $event.target || $event.srcElement;
this.fileUploadService.addToQueue(target.files);
target.value = '';
}
WORK FOR ME
you need to empty the input file value after upload
here the code worked for me
HTML:
<input type="file" name="myfile" #activeFrameinputFile ng2FileSelect [uploader]="frameUploader" (change)="frameUploader.uploadAll()" />component
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';@ViewChild('activeFrameinputFile') InputFrameVariable: ElementRef;this.frameUploader.onSuccessItem = (item, response, status, headers) => {this.InputFrameVariable.nativeElement.value = '';};this will definitely works
if (this.selectedFiles.length === 0) { this.epubFileUploader.nativeElement.value = ''} worked for me..