title: PHP and MySQLi - Upload Multiple Image
body: <p>I am planning to make an image galary using PHP with MySQL as a database.</p>
  
  <p>I already make a multiple upload images using PHP but I got a problem. When I uploaded <strong>8 images</strong> in database only show 1 row data. But in folder there are <strong>8 images</strong> that I have upload.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;form action="a.php" method="post" enctype="multipart/form-data"&gt;
  &lt;input type="file" name="file_img[]" multiple&gt;
  &lt;input type="submit" name="btn_upload" value="Upload"&gt;    
  &lt;/form&gt;
  
  &lt;?php
  include_once 'koneksi.php';
  if(isset($_POST['btn_upload']))
  {
      for($i = 0; $i &lt; count($_FILES['file_img']['name']); $i++)
      {
          $filetmp = $_FILES["file_img"]["tmp_name"][$i];
          $filename = $_FILES["file_img"]["name"][$i];
          $filetype = $_FILES["file_img"]["type"][$i];
          $filepath = "uploads/".$filename;
  
      move_uploaded_file($filetmp,$filepath);
  
      $sql = "INSERT INTO files (file,path,type) VALUES ('$filename','$filepath','$filetype')";
      if($connect-&gt;query($sql) === TRUE) {        
  header("Location: a.php");    
  } else {        
  header("Location: a.php");    
  }     
      }
  
      $connect-&gt;close();}
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can someone help me ? Thanks for ur feedback :)</p>