title: Image upload multiple maximum of four images only [php]
body: <p>This is my code in uploading an image. It is working but only one image. I wanted to change it so that it will enable my users to upload maximum of 4 images. Could anyone guide me on this?</p>
  
  <pre><code>if(isset($_FILES['image'])){
      $file_name = $_FILES['image']['name'];
      $file_size =$_FILES['image']['size'];
      $file_tmp =$_FILES['image']['tmp_name'];
      $file_type=$_FILES['image']['type'];   
      $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
  
  
      $extensions= array("jpeg","jpg","png","gif","");        
      if(in_array($file_ext,$extensions) === false){
          $msg = '&lt;div class="error"&gt;Extension not allowed, please choose a JPEG or PNG file.&lt;/div&gt;'; 
      }
      if($file_size &gt; 10000000){
          $msg = '&lt;div class="error"&gt;File size must not be larger than 10MB&lt;/div&gt;';
      }
  
      if(empty($msg)==true){
          $newname= (rand(1, 99999999999).".".$file_ext);     
          $dir_separator = DIRECTORY_SEPARATOR;
          $folder = "uploads";
  
          $uploaddate = date("M-d-Y");
  
          $destination_path = dirname(__FILE__).$dir_separator.$folder.$dir_separator.$uploaddate.$dir_separator;
  
          if(!is_dir($destination_path)) mkdir($destination_path);
  
          $target_path = $destination_path.$newname;
          move_uploaded_file($file_tmp, $target_path);
  
          if(empty($file_name) == false){
          $file_location = "/".$uploaddate."/".$newname;
           }
          else
           { 
           $file_location = "";
           }
  
          //SQL Insert code here
          echo "Upload complete";
  
      }
  }
  </code></pre>
  
  <p>This is my form</p>
  
  <pre><code>&lt;form id="support-form" action="" name="support-form" method="POST" enctype="multipart/form-data"&gt;
              &lt;div class="subject-message-wrap"&gt; &lt;br/&gt;
                  &lt;div class="message-text" style="text-align:center;"&gt;
                      &lt;textarea name="message" id="message" rows="5" style="width:98%; max-width: 98%;" placeholder="Write your reply here..." required&gt;&lt;/textarea&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;!---UPLOAD FILE---&gt;
              &lt;div class="wrap-upload"&gt;
                  &lt;div&gt;
                  &lt;label style="color:#009fdb;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Attach an image: &lt;/label&gt;
                  &lt;input type="file" name="image" id="image" multiple/&gt;
  
                  &lt;/div&gt; 
                  &lt;br/&gt;
                  &lt;div class="submit-button-wrap"&gt;
                  &amp;nbsp;&amp;nbsp;&amp;nbsp;
                  &lt;input type="submit" value="Reply" name="submit" id="submit"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="submit" value="Cancel" name="cancel" id="cancel"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;!---Code End UPLOAD FILE---&gt;
              &lt;/form&gt;
  </code></pre>
  
  <p>Edited #1:
  Issue on my database table. My table looks like this.</p>
  
  <p><a href="https://i.stack.imgur.com/hJEMF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJEMF.jpg" alt="table name = support"></a></p>
  
  <p>What i'm thinking is to add new 3 fields for the additional image location(url). Any other good idea better than mine?</p>