title: getimagesize() expects parameter 1 to be string, array given
body: <p>I am using getimagesize to validate the image type but don't know how to write the script for multiple file.  Basically, I have a form that will allow upload of multiple image files like below.</p>
  
  <pre><code>  &lt;input type="file" name="photo[]" class="file" /&gt;
    &lt;input type="file" name="photo[]" class="file" /&gt;
    &lt;input type="file" name="photo[]" class="file" /&gt;
  </code></pre>
  
  <p>Then I am using this to validate it and send via phpmailer.</p>
  
  <pre><code>&lt;?php
  ob_start();
  require("class.phpmailer.php");
  
  $errors = array();
  
  if ('POST' === $_SERVER['REQUEST_METHOD'])
  {
      $firstname           = sanitize($_POST['firstname']);
      $lastname           = sanitize($_POST['lastname']);
      $email                 = sanitize($_POST['email']);
  
      if (empty($firstname))
      {
          $errors['firstname'] = "Please provide first name.";
      }
      if (empty($lastname))
      {
          $errors['lastname'] = "Please provide last name.";
      }
      if (!filter_var($email, FILTER_VALIDATE_EMAIL))
      {
          $errors['email'] = "Please provide a valid email address.";
      }
  
      if (count($errors) === 0)
      {
  
  
  $imageinfo = array();
    $my_files = $_FILES['photo']['tmp_name'];
    foreach($my_files as $single_file) {
    if(!empty($single_file)) {
    $imageinfo[$single_file] = getimagesize($single_file);
    if ($single_file['mime'] != 'image/png' &amp;&amp; $single_file['mime'] != 'image/jpeg')
    { echo "Invalid Image File";
    exit();
    }  }
    }
  
  
  foreach($_FILES['photo']['tmp_name'] as $photo) 
  if(!empty($photo)) {
  $mail-&gt;AddAttachment($photo);
  
  
  $message = 'some message';
  
  $mail = new PHPMailer();
  
  $mail-&gt;SetFrom($email);
  $mail-&gt;AddAddress($from);
  
  $mail-&gt;Subject  = "Submitted";
  $mail-&gt;Body     = $message;
  $mail-&gt;WordWrap = 50;
  }
  
  $mail-&gt;Send();
  
  header("Location: thankyou.php");
  exit();     
  }}
  
  function sanitize($value)
  {
      return trim(strip_tags($value, $problem=''));
  }
  ?&gt;
  </code></pre>
  
  <p>I am getting error message of <strong>Warning: getimagesize() expects parameter 1 to be string, array given</strong>  I know this is because of my form is passing a array.  How do I change the script to work for multiple files/arrays?  please help.  thx.</p>