ng2-file-upload icon indicating copy to clipboard operation
ng2-file-upload copied to clipboard

How to repeat uploading of the same file (after failed server side validation on other form fields)

Open dj-at-work opened this issue 9 years ago • 5 comments

I've added additional form data (as described here #241). If the server side validation fails I show an error on the related form field. The user can fix it and repeat the upload of the complete form just by a click on the upload button.

Unfortunately I don't find a way to tell the uploader to upload the current file again. I played around with the FileItem, tried to set isUploaded and isSuccess to false, but nothing works.

Does anyone know how to solve this?

dj-at-work avatar Jun 30 '16 09:06 dj-at-work

Did you ever find a solution to this? I have the same issue

markkesty avatar Dec 14 '16 16:12 markkesty

Dear @TheNightbear, @markkesty,

You should set isUploaded property on FileItem object set to false, afterr unsuccess upload attempt, like below:

uploader.queue[0].isUploaded = false;

Have a nice day!

fuitattila avatar Jan 25 '17 10:01 fuitattila

you need to empty the input file value 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

javascriptsoldier avatar Dec 04 '18 11:12 javascriptsoldier

How do we mark a particular chunk as not uploaded so that i can retry only that chunk

dotnetgik avatar Apr 08 '20 14:04 dotnetgik