title: how to move uploaded multiple images at once in php
body: <p>I'm trying to upload 3 images fields, store them in my database and move the uploaded file in a folder.</p>
  
  <p>For now, the "image1", 'image2", "image3", "image4" fields are inserting into MySQL database, but only "image1" is uploading and moving into my folder.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>if(isset($_POST['submit'])){
    $pro_image1 = $_FILES['image1']['name'];
    $pro_image2 = $_FILES['image2']['name'];
    $pro_image3 = $_FILES['image3']['name'];
    $pro_image4 = $_FILES['image4']['name'];
    $tmp_name   = $_FILES['image1']['tmp_name'];
    $tmp2_name  = $_FILES['image2']['tmp_name'];
    $tmp3_name  = $_FILES['image3']['tmp_name'];
    $tmp4_name  = $_FILES['image4']['tmp_name'];
  
    $pro_query = "INSERT INTO product(image1,image2,image3,image4) VALUES('$pro_image1','$pro_image2','$pro_image3','$pro_image4')";
  
    if(mysqli_query($con,$pro_query)){
      $msg = "&lt;p class='pull-right' style='color:green;'&gt; Product Added successfully&lt;/p&gt;";
      $path = "images/$pro_image1";
  
      if(move_uploaded_file($tmp_name, $path)) {
        copy($path, "../$path");
      }
  
      if(move_uploaded_file($tmp2_name, $path)) {
        copy($path, "../$path");
      }
  
      if(move_uploaded_file($tmp3_name, $path)) {
        copy($path, "../$path");
      }
  
      if(move_uploaded_file($tmp4_name, $path)) {
        copy($path, "../$path");
      } elseif(!mysqli_query($con,$pro_query)) {
        $insert_error = "&lt;p class='pull-right' style='color:red;&gt;Product didn't added&lt;/p&gt;";
      }
    }
  }
  
  &lt;form action="" method="post" enctype="multipart/form-data"  class="form-font"&gt;
    &lt;div class="col-md-6"&gt;
      &lt;div class="form-group"&gt;
        &lt;label&gt;Image1&lt;/label&gt;
        &lt;input type="file" name="image1" class="form-control" required&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label&gt;Image2&lt;/label&gt;
        &lt;input type="file" name="image2" class="form-control" required&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label&gt;Image3&lt;/label&gt;
        &lt;input type="file" name="image3" class="form-control" required&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
        &lt;label&gt;Image4&lt;/label&gt;
        &lt;input type="file" name="image4" class="form-control" required&gt;
      &lt;/div&gt;
      &lt;center&gt;
        &lt;input type='submit' name='submit' class='btn btn-success' value='Add Product'&gt;
      &lt;/center&gt;
    &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>How to move the other images ("image2", "image3", "image4") in my folder?<br>
  What is the mistake I made in my code? Could you please explain me where I am doing wrong ?</p>