title: Validating multiple files (IMG) in PHP
body: <p>I'm creating a website where I ask for a file in a form:</p>
  
  <pre><code>            &lt;input id="foto-disfraz[]" name="foto-disfraz[]" type="file"/&gt;
              &lt;button type='button' class="agregarotra"&gt;Agregar otra foto&lt;/button&gt;
              &lt;span class="error"&gt;&lt;?= $fotoErr ?&gt;&lt;/span&gt; 
  </code></pre>
  
  <p>You can add more files using the button "agregarotra" next to it , that uses a JS:</p>
  
  <pre><code>
      jQuery(document).ready(function() {
          var nfotos = 1;
          $('.agregarotra').click(function(e) {
              e.preventDefault();
              if (nfotos &lt; 5) {
                  $(this).before("&lt;input id='foto-disfraz[]' name='foto-disfraz[]' type='file'/&gt;");
                  nfotos++;
              } else {
                  alert("Ya tienes el máximo numero de fotos posibles");
              }
          });
      });
  
  </code></pre>
  
  <p>I have to validate every file added in the form, they are required so I must have at least one file.
  If i have more I have to verify every file added by the user.
  Right now im trying to at least verify one file, so my idea is to verify that foto-disfraz is not empty, and then adding to the variable $foto the file, so I can add it later to a database.</p>
  
  <pre><code>    $foto=$fotoErr='';
      ...
        if(isset($_FILES["foto-disfraz[]"])) {
          $foto = $_FILES["foto-disfraz[]"];
        }
        else {
          $fotoErr = "* Foto es obligatoria";
        }
      ...
      }
  </code></pre>
  
  <p>So right now my problem is that it always gives me the error, it seems that it doesnt save the file in the variable im trying to save to. I don't know if I'm using the <code>_FILE</code> method right or my condition on the if is failing due they can be multiple files or something.
  I dont know what else I can add as detail so if I'm missing something important to add besides the code I can edit and update.</p>