title: php upload file issue using array
body: <p>in my form I'm trying to upload multiple or single file using php. So my html table is look like this : </p>
  
  <pre><code>&lt;tr&gt;
  &lt;td width="142"&gt;&lt;b&gt;Docs&lt;/b&gt;
  &lt;td width="142"&gt;&lt;input type="file" name="files[]" id="project_docs1" class="docfile" /&gt;&lt;/td&gt;
  &lt;td width="142"&gt;&lt;input type="file" name="files[]" id="project_docs2" class="docfile" /&gt;&lt;/td&gt;
  &lt;td width="142"&gt;&lt;input type="file" name="files[]" id="project_docs3" class="docfile" /&gt;&lt;/td&gt;
  &lt;/td&gt;
  </code></pre>
  
  <p></p>
  
  <p>Now when I upload only one file it's showing me error message like : Invalid Format but it's should be accept one file. it's not require to must be upload all 3 files. Can you tell me why it's showing this error message called <strong>Invalid Format</strong> ? If upload all 3 files then it's working fine. </p>
  
  <p>and when I press the upload button without upload any file it's showing me value 1 for <code>$noOfUpload</code> variable. why ?</p>
  
  <pre><code>$valid_formats = array("jpg", "png", "gif", "txt", "bmp");
  $max_file_size = 1024*100; //100 kb
  $path = "project_docs"; // Upload directory
  $error =  array();  // load error message
  $files_name =  array(); // get uploaded file name
  
  foreach ($_FILES['files']['name'] as $key =&gt; $name) {
  
      $size = $_FILES['files']['size'][$key]. "&lt;br&gt;"; 
      $noOfUpload = count($name);
  
      if($noOfUpload &lt;= 0){
          $error[] =  "Upload your document/s&lt;br&gt;";
      }elseif(!in_array(pathinfo($name, PATHINFO_EXTENSION), $valid_formats)){
          $error[] = "invalid file formate : $name&lt;br&gt;";
  
      }
  
      //$name = md5(uniqid()) . '-' . htmlspecialchars_decode($name);
      $files_name[] = "$name";
  
  }
  
  if(!empty($error)){
      foreach ($error as $e) {
          echo "&lt;div class='error'&gt;$e&lt;/div&gt;";
      }   
  }else{
      foreach ($files_name as $fn) {  
          echo "$fn&lt;br&gt;";
      }       
  }
  </code></pre>
  
  <p>You help is more appreciate. :)</p>