0

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!

Sarius
  • 125
  • 2
  • 16

1 Answers1

0

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;}
});
Prikesh Savla
  • 356
  • 2
  • 5