function removeFile(index){
var attachments = document.getElementById("attachment").files; // <-- reference your file input here
var fileBuffer = new DataTransfer();
// append the file list to an array iteratively
for (let i = 0; i < attachments.length; i++) {
// Exclude file in specified index
if (index !== i)
fileBuffer.items.add(attachments[i]);
}
// Assign buffer to file input
document.getElementById("attachment").files = fileBuffer.files; // <-- according to your file input reference
}