title: check the number of files before uploading (jquery)
body: <p>I am trying to check the number of files before uploading.
  I want to allow 3 images only.</p>
  
  <pre><code> &lt;form   action="upload.php"   enctype="multipart/form-data"   method="post"&gt; 
             &lt;input type="file" name="image[]"  multiple="multiple" /&gt; 
        &lt;input type="submit"   value=" Upload "  class="submit"  /&gt;   
  &lt;/form&gt;
  
  $(function() {
    $(".submit").click(function() {
  
        var numFiles = $("[name='image[]']", this)[0].files.length;
  
        if (numFiles &gt; 3) {
                 alert(numFiles);
           ;}     
  
      }); 
  
   });
  </code></pre>
  
  <p>This is the demo:
  <a href="http://jsfiddle.net/Ld7fE/5/" rel="nofollow">http://jsfiddle.net/Ld7fE/5/</a></p>
  
  <p>How can I fix this issue?
  Thank you </p>