title: Resize image in the client side before upload
body: <p>Is there any client side script can resize automatically the image uploaded in the input file by the user, and replace automatically the old image by the new image resized in the same input ..I want to do this to send this image to my php model after.. thanks in advance for your help.</p>
  
  <pre><code> &lt;!DOCTYPE HTML&gt;
   &lt;html&gt;
   &lt;head&gt;
       &lt;title&gt;Untitled&lt;/title&gt;
   &lt;/head&gt;
   &lt;body&gt;
      &lt;form action="model.php" method="post" enctype="multipart/form-data"&gt;
         &lt;input type="file" name="image"/&gt;
         &lt;input type="submit" name="do" value="submit"/&gt;
      &lt;/form&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  
  &lt;?php
  $target_dir = "folder/";
  $filename    = $_FILES["image"]["name"];
  $basename    = basename($_FILES["image"]["name"]);
  $target_file = $target_dir .$basename;
  $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
  $tmp         = $_FILES["image"]["tmp_name"];
  if(move_uploaded_file($tmp,$target_file))
  {
      echo'done!';
  }
  ?&gt;
  </code></pre>