title: How to Save multiple images on database using PHP Script
body: <p>On my custom CMS, </p>
  
  <p>I am successfully able to save all the values from the admin form into the database.</p>
  
  <p>All of these have a single value, but what about multiple element? </p>
  
  <p>How can I save the input file with more than one image ?</p>
  
  <p>Here is my full code of the add post page:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['submit'])) {
      $title_bg = $_POST['title_bg'];
      $title_en = $_POST['title_en']; 
      $body_bg = $_POST['body_bg'];
      $body_en = $_POST['body_en'];   
      $image = $_FILES['image']['name'];
      $image_tmp = $_FILES['image']['tmp_name'];  
  
      move_uploaded_file($image_tmp, '../uploads/' . $image);
  
      $status = $_POST['status'];
  
  
      $query = "INSERT INTO posts(title_bg, title_en, body_bg, body_en, image, status, created) ";
      $query .= "VALUES('$title_bg', '$title_en', '$body_bg', '$body_en', '$image', '$status', now())";
  
      $create_post = mysqli_query($connection, $query); 
  
      header("Location: posts.php");  
  } 
  ?&gt;
  
  &lt;form action="" method="post" enctype="multipart/form-data"&gt;
      &lt;div class="form-item"&gt;
          &lt;label for="title_bg"&gt;Post title BG&lt;/label&gt;
          &lt;input type="text" name="title_bg"&gt;
      &lt;/div&gt;
  
      &lt;div class="form-item"&gt;
          &lt;label for="title_en"&gt;Post title EN&lt;/label&gt;
          &lt;input type="text" name="title_en"&gt;
      &lt;/div&gt;  
  
      &lt;div class="form-item"&gt;
          &lt;label for="body_bg"&gt;Post body BG&lt;/label&gt;
          &lt;textarea id="editor" name="body_bg" rows="10" cols="30"&gt;&lt;/textarea&gt;
      &lt;/div&gt;  
  
      &lt;div class="form-item"&gt;
          &lt;label for="body_en"&gt;Post body EN&lt;/label&gt;
          &lt;textarea id="editor2" name="body_en" rows="10" cols="30"&gt;&lt;/textarea&gt;
      &lt;/div&gt;  
  
      &lt;div class="form-item"&gt;
          &lt;label for="image"&gt;Image&lt;/label&gt;
          &lt;input type="file" name="image"&gt;
      &lt;/div&gt;
  
      &lt;div class="form-item"&gt;
          &lt;label for="status"&gt;Post status&lt;/label&gt;
          &lt;select name="status"&gt;
              &lt;option value="published"&gt;published&lt;/option&gt;
              &lt;option value="draft"&gt;draft&lt;/option&gt;
          &lt;/select&gt;
      &lt;/div&gt;
  
      &lt;div class="form-item"&gt;
          &lt;input type="submit" class="form-submit" name="submit" value="Submit"&gt;
      &lt;/div&gt;  
  &lt;/form&gt;
  </code></pre>
  
  <p>Right now the image value is saving into the database image field like this:
  sample-1.jpg.</p>
  
  <p>As far as I know, in HTML multiple element has the attribute <strong>multiple</strong> and using array this line should be like this:</p>
  
  <pre><code>&lt;input type="file" name="image[]" multiple&gt;
  </code></pre>
  
  <p>but how do I set an array element $image and save the multiple values into one field, so when I upload let's say three images, the saved values in the database image field should be like this:
  sample-1.jpg, sample-2.jpg, sample-3.jpg</p>