nicematt nicematt - 3 months ago 6
HTML Question

Update the status of a input[type=file] when change files

I've this file input:

<input type="file" id="fileSelector" multiple="true">


If I add or remove files inside this input, it doesn't update its text.

fileSelector.files = [];


E.g, if its text is "2 files selected" and I change the
files
array, it doesn't update this text.

How to update this text?

Answer

It is not possible to set the value of FileList of <input type="file"> element .files programmatically; FileList is read-only