0

I tried to remove one of the files in FileList, but I found that FileList is not an Array, and I cannot remove one of its elements through splice:

file: {
    files: FileList,
  }={
    files: {} as FileList
  }


 this.file.files.splice(index, 1);

// error message:
// Property 'splice' does not exist on type 'FileList'.

But through the for loop, you can see each file correctly:

for (let i = 0; i < this.file.files.length; i++) {
      let file = this.file.files[i]; 
      console.log(file);
    }
Finn
  • 1,323
  • 5
  • 24
  • 46
  • Does this answer your question? [How do I remove a file from the FileList](https://stackoverflow.com/questions/3144419/how-do-i-remove-a-file-from-the-filelist) – Yong Shun Jun 30 '23 at 03:31
  • @YongShun I have seen a discussion but it doesn't seem to solve my problem, he doesn't seem to be manipulating a `FileList` – Finn Jun 30 '23 at 03:49

0 Answers0