title: How to loop this code to compress multiple image at a time
body: <p>This is my code to compress images in php but i don't know how to loop them so user may enter multiple files and then it's get convert. Is it is possible to do???
  Here's my php code snippet</p>
  <pre><code>&lt;?php
  /*$input_image=&quot;sample.jpg&quot;;
  $output_image=&quot;output.jpg&quot;;
  
  $img=imagecreatefromjpeg($input_image);
  imagejpeg($img,$output_image,10);*/
  if(isset($_POST['submit'])){
      $info=getimagesize($_FILES['image']['tmp_name']);
      if(isset($info['mime'])){
          if($info['mime']==&quot;image/jpeg&quot;){
              $img=imagecreatefromjpeg($_FILES['image']['tmp_name']);
          }elseif($info['mime']==&quot;image/png&quot;){
              $img=imagecreatefrompng($_FILES['image']['tmp_name']);
          }else{
              echo &quot;Only select jpg or png image&quot;;
          }
          if(isset($img)){
              $output_image=time().'.jpg';
              imagejpeg($img,$output_image,40);
              echo &quot;Processing done&quot;;}
      }else{
          echo &quot;Only select jpg or png image&quot;;
      }
  }
  ?&gt;
  </code></pre>
  <p>My html code snippet</p>
  <pre><code>&lt;form method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
      &lt;input type=&quot;file&quot; name=&quot;image&quot; required/&gt;
      &lt;input type=&quot;submit&quot; name=&quot;submit&quot;/&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Any help will be appreciated. Thankyou.</p>