I got the job to add a delete function to a html input with type "file", which can delete a single file from a list of multiple files. As you can see in the snippet below, deleting all files at once is easily done, but my function to delete one file at a certain index is not working.
function remove(i){
document.getElementById('files').files.splice(i, 1);
}
function removeAll(){
document.getElementById("files").value=null;
}
<input id="files" type="file" multiple="multiple">
<button onclick="remove(1)">delete 1st</button>
<button onclick="remove(2)">delete 2nd</button>
<button onclick="remove(3)">delete 3rd</button>
<button onclick="removeAll()">delete all</button>
Is there any way to make this remove()
-function work?