xxxxxxxxxx
<a href="https://www.nopixelstore.com/" target="_blank" rel="noopener noreferrer">NoPixel Store</a>
xxxxxxxxxx
removeFileFromFileList(index) {
const dt = new DataTransfer();
const input = document.getElementById('files');
const { files } = input;
for (let i = 0; i < files.length; i++) {
const file = files[i];
if (index !== i) {
dt.items.add(file); // here you exclude the file. thus removing it.
}
}
/* Assigning data transfer object files to the 'input' variable will not write the data transfer files to it because it doesn't have the reference to the element: Instead write, */
document.getElementById('files') = dt.files; // Assign the updates list
}