title: PHP: Uploading multiple files: Notice: Undefined index: file in bulletin.php
body: <p>When I select a single file or multiple files, the result is the same.  I am expecting this code to upload multiple files.  But the array is empty.  I have reviewed multiple posts by others and the answers to those questions don't seem to apply here.  If I eliminate all form inputs except the hidden input with name 'action' the uploads work just fine.  </p>
  
  <p>Here is the relvant HTML form:</p>
  
  <pre><code>&lt;form action="bulletin.php" method="post" enctype="multipart/form-data"&gt;
  &lt;input class="form-control" id="message_subject" name="message_subject" type="text"/&gt;
  &lt;textarea class="form-control" cols="40" id="message_body" name="message_body" rows="10"&gt;&lt;/textarea&gt;
  &lt;input type="file" id="file" name="file[]" multiple accept="image/*"/&gt;
  &lt;input type="hidden" name="action" value="submit_new"&gt;
  &lt;button class="btn btn-primary " name="submit" type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the PHP:</p>
  
  <pre><code>print_r($_FILES);       
  if(isset($_POST['action'])){
  
  // Count total files
  $countfiles = count($_FILES['file']['name']);
  
  // Looping all files
  for($i=0;$i&lt;$countfiles;$i++){
  $filename = date('Y-m-d-H-i-s') . $_FILES['file']['name'][$i];
  
  // Upload file
  move_uploaded_file($_FILES['file']['tmp_name'][$i],'user-images/'.$filename);
  
  }
  }
  </code></pre>
  
  <p>Here is the output:</p>
  
  <p>Array ( )</p>
  
  <p>Notice: Undefined index: file in /var/www/html/secure/bulletin.php on line 66</p>
  
  <p>Why is the array empty when there are other inputs included on form?</p>