Solution 1 :

You can use the files attribute of the file input to determine how many files are in it.

$('.fileinput').change(function(){
    if(this.files.length>10){
        alert('Too many files');
    }
     //U can set value = ''; if you dont want to allow submissions

});
// Prevent submission if limit is exceeded.
$('form').submit(function(){
    if(this.files.length>10){
       return false;}
});

Problem :

Is There a way to limit the maximum number of files that can be uploaded in a multiple-file-input-field? I don’t mean the maximum number of files uploaded in one stack by choosing from the file-explorer, but added to the input field at all.

Thanks in advance!

Comments

Comment posted by Prikesh Savla

do you want to limit it before it being added?

Comment posted by Sarius

@PrikeshSavla Im not sure i understand the Question. I want to limit the absolute number of files uploaded, no matte rhow often the user chooses new files. so i guess the answer to your question would be yes

Comment posted by Prikesh Savla

But you dont mind it the validation happens after the user has chosen the files right?

Comment posted by stackoverflow.com/questions/15854946/…

stackoverflow.com/questions/15854946/…

By