How can restrict user to upload max 10 files at once?

前端 未结 2 483
無奈伤痛
無奈伤痛 2021-01-15 01:58

I am using in my web page to upload files (using ajaxupload). It will allow user to upload multip

2条回答
  •  被撕碎了的回忆
    2021-01-15 02:42

    
    
    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.

提交回复
热议问题