1

I want to select multiple images but max 5 images and after 5 images when user click on 6th images then the user not allowed to select more than 5 images.

Below what I am doing:

       <input class="form-control" type="file" name="photo[]" id="photo" multiple max-uploads = "5" >


<script>
$(function(){
          $("input[type = 'submit']").click(function(){
             var $fileUpload = $("input[type='file']");
             if (parseInt($fileUpload.get(0).files.length) > 5){
                alert("You are only allowed to upload a maximum of 5 files");
             }

          });
       });

</script>

In this case I need to click submit button. I want when user select the image and if image more than 5 then user not able to select the 6th image.

I want to SET the select limit.

Kindly suggest me what I am doing wrong. Your valuble suggestions would be welcome.

Sarah
  • 405
  • 2
  • 7
  • 23
  • 1
    @TRent, No that is not what I want. In your answer user is able to select more than 2 files. When click submit then alert come. I dont want this, kindly check my question. I want user not able to select more than 5 images. Simple. I don't understand why people are giving the solution what I don't want. I clearly mention in my question what I don't want. Anyway, Thanks for the answer. Hope it help someone else. – Sarah Sep 07 '18 at 09:24

0 Answers0