0

I am currently using a cool cropping plugin called cropit. I want to upload multiple images at once via <input type="file" multiple/>, crop them and save them at once.

My aim is to have the possibility to upload images from a smartphone, since it isn't quite user friendly to upload every image separately. But! I want to limit the image selection to 12 images. Is there a way to achieve it?

PLAYCUBE
  • 795
  • 4
  • 14
  • 24
  • You cant avoid selecting more than 12, but you can simply check how many of them are selected and warn the user etc.. – abeyaz Jan 14 '17 at 13:03
  • 2
    Possible duplicate of [How to limit maximum items on a multiple input ()](http://stackoverflow.com/questions/10105411/how-to-limit-maximum-items-on-a-multiple-input-input-type-file-multiple) – Lucas Bustamante Jan 14 '17 at 13:21

1 Answers1

0

Try this this is simple to understand and apply. here you are just checking if there is 13th file selected then you get your if block to do code.

$("#abc").change (function(){
  if(this.files[12]){
    alert('not allowed!');
  }
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<input type="file" multiple id="abc">
codenut
  • 683
  • 1
  • 7
  • 21