When input file multiple, what if the file name cannot be duplicated?

input file multiple multiple file upload, how to check that the file name can not be duplicated?

Apr.02,2021

event.files is the list of files you uploaded

//
let flag = false;
for(let i = 0;i<event.files.length-1;iPP){
    for(let j = i+ 1;j<event.files.length;jPP){
        if(event.files[i].name==event.files[j].name) flag=true
    }
}
//
const arr = Array.from(event.files).map(item=>item.name)
//set
const set = new Set(arr)
//set
if(set.length!=arr.length){
    ...
}
Menu