title: Resize image before uploading PHP
body: <p>I have no idea how to resize image in PHP, my code is:</p>
  
  <pre><code>for ($index = 1; $index &lt;= 2; $index++) { 
  
      if (!empty($_FILES["pic$index"]["name"])) {
          $ext = substr($_FILES["pic$index"]["name"], strrpos($_FILES["pic$index"]["name"], '.') + 1);
          $dir = "../gallery/$mkdir";
  
          HERE I NEED THE RESIZE OF THE TMP FILE OF IMAGE
  
          move_uploaded_file($_FILES["pic$index"]["tmp_name"] , "$dir/img-$index.$ext");
  
      }  
  
  }
  </code></pre>
  
  <p>$mkdir = the name of the gallery's folder (there are many galleries).</p>
  
  <p>$dir = where the pics will be placed.</p>
  
  <p>$ext = the type of the image (png, gif or jpg).</p>
  
  <p>foreach loop runs two times because you can upload two pics.</p>
  
  <p>This script is working good, I just need to do resize and I dont have an idea how to do it..</p>