title: Multiple Image Upload PHP form with one input
body: <p>I've been trying to make this work for quite some time now. But I can't seem to make it work. I wanted to have a multiple image upload form with only using one input. </p>
  
  <p>this is my upload.php</p>
  
  <pre><code>&lt;?php
  include("../include/session.php");
  
  session_start();
  $allowedExts = array("jpeg", "jpg", "png", "gif");
  $extension = end(explode(".", $_FILES["upload"]["name"]));
  
  if(isset($_FILES['upload']['tmp_name']))
  {
      for($i=0; $i &lt; count($_FILES['upload']['tmp_name']);$i++)
      {
  
          if (($_FILES["upload"]["name"] &lt; 90000000000000000)
              &amp;&amp; in_array($extension, $allowedExts)) {
                  if ($_FILES["upload"]["error"] &gt; 0)
                  {
                      header('location: '.$error); die;
                  }
                  else
                  {
  
                      if (file_exists("../icons/".$_SESSION["username"] ."/" . $_FILES["upload"]["name"]))
                      {
                      echo "error";
                      }
                      else
                      {
                          if(!is_dir("../icons/". $_SESSION["username"] ."/")) {
                              mkdir("../icons/". $_SESSION["username"] ."/");
                          }
  
                          $temp = explode(".",$_FILES["upload"]["name"]);
                          $file = rand(1,999999999999) . '.' .end($temp);
  
                          move_uploaded_file($_FILES["upload"]["tmp_name"], "../icons/". $_SESSION["username"] ."/". $file);  
                      }
                  }
              }
          } else {
              echo "yep error";
          }
      }
  } 
  ?&gt;
  </code></pre>
  
  <p>if i take out the lines</p>
  
  <pre><code>if(isset($_FILES['upload']['tmp_name']))
  {
      for($i=0; $i &lt; count($_FILES['upload']['tmp_name']);$i++)
      {
  </code></pre>
  
  <p>With the corresponding closing bracket, it seems to work fine. The image is uploaded perfectly. But the thing is, it only allows me to upload one. </p>
  
  <p>Please I really need your expertise. THank you</p>