function checkFiles(files) {
if(files.length>10) {
alert("length exceeded; files have been truncated");
let list = new DataTransfer;
for(let i=0; i<10; i++)
list.items.add(files[i])
document.getElementById('files').files = list.files
}
}
This function will not allow to select files more than 10.