2

I have input type=file for upload file. When I choose 2-3 files, I have list of file. How can I delete only one object which I choose?

<input type="file"  data-ng-click="initFiles2()" data-rule-required="true" id="file"  name="file[]"   multiple data-ng-model="file" />

I tried like other object from list I delete but in this case is not working.

I tried something like this but not working ...

var index = -1;     
    for( var i = 0; i < file.files.length; i++ ) {
        if( file.files[i].name === name ) {
            index = i;
            break;
        }
    }
    file.files.splice( index, 1 );

'name' is name of the file

Markus
  • 3,225
  • 6
  • 35
  • 47
zexco2
  • 149
  • 2
  • 18
  • you can dupe inp.files to an array and censor it to your liking... – dandavis May 10 '15 at 08:42
  • You are right, I will do that ... – zexco2 May 10 '15 at 12:34
  • Possible duplicate of [How to remove one specific selected file from input file control](https://stackoverflow.com/questions/19060378/how-to-remove-one-specific-selected-file-from-input-file-control) – Endless Dec 09 '17 at 12:55

1 Answers1

0

You can't. The user can, but you can't. There are no methods on FileList that allow you to modify it.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • If the user selects 10 files and displayed his list of files, whether this means that there is no possibility that over some functions give him the ability to delete a one file? Must all reset if one file wrongly chosen? – zexco2 May 10 '15 at 08:15