title: Only last image uploaded from array when uploading multiple images in MYSQL with PHP
body: <p>I'm trying to upload multiple images from a textbox to MYSQL database using PHP.
  But somehow it only inserts the last item from the array in the database.</p>
  
  <p>I tried uploading using one image, and that worked.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>form.php:</strong></p>
  
  <pre><code>&lt;form action="addpicture.php?id=&lt;?php echo $prodID; ?&gt;" method="POST" enctype="multipart/form-data"&gt;  
      &lt;input type="file" name="image[]" multiple/&gt;
      &lt;input type="submit" value="upload" name="image" class="btn btn-primary" /&gt; 
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Addpicture.php:</strong></p>
  
  <pre><code>    &lt;?php
      session_start();
      include '../includes/config.php';
  
      $prodID = $_GET['id'];
  
      foreach(array_keys($_FILES['image']['error']) as $key){
      $temp_name = $_FILES['image']['tmp_name'][$key];
      $t_name = file_get_contents($temp_name);
      $t_name = mysql_real_escape_string($t_name);
  
      $insert = mysql_query("INSERT INTO tblpictures(prodID, foto) VALUES ('$prodID','$t_name')") or die(mysql_error());          
  
              header('location: form.php?prodID=' . $prodID);
              exit();
      }
  
      ?&gt;
  </code></pre>
  
  <p><strong><em>EDIT: SOLVED</em></strong>
  <a href="https://stackoverflow.com/questions/3215324/html-5-multi-file-upload-with-php">HTML 5 multi file upload with PHP</a></p>