title: how to save cropped image
body: <p>Downloaded the code for cropping image from the following link:</p>
  
  <p><a href="http://deepliquid.com/content/Jcrop.html" rel="nofollow">http://deepliquid.com/content/Jcrop.html</a></p>
  
  <p>This is the code in crop.php page:</p>
  
  <pre><code>&lt;?php
  
  /**
   * Jcrop image cropping plugin for jQuery
   * Example cropping script
   * @copyright 2008-2009 Kelly Hallman
   * More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html
   */
  
  if ($_SERVER['REQUEST_METHOD'] == 'POST')
  {
      $targ_w = $targ_h = 150;
      $jpeg_quality = 90;
  
      $src = 'demo_files/pool.jpg';
      $img_r = imagecreatefromjpeg($src);
      $dst_r = ImageCreateTrueColor( $targ_w, $targ_h );
  
      imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],
      $targ_w,$targ_h,$_POST['w'],$_POST['h']);
  
      header('Content-type: image/jpeg');
      imagejpeg($dst_r,null,$jpeg_quality);
  
      exit;
  }
  
  // If not a POST request, display page below:
  
  ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
          &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script src="js/jquery.Jcrop.js"&gt;&lt;/script&gt;
          &lt;link rel="stylesheet" href="css/jquery.Jcrop.css" type="text/css" /&gt;
          &lt;script language="Javascript"&gt;
  
              $(function(){
  
                  $('#cropbox').Jcrop({
                      aspectRatio: 1,
                      onSelect: updateCoords
                  });
  
              });
  
              function updateCoords(c)
              {
                  $('#x').val(c.x);
                  $('#y').val(c.y);
                  $('#w').val(c.w);
                  $('#h').val(c.h);
              };
  
              function checkCoords()
              {
                  if (parseInt($('#w').val())) return true;
                  alert('Please select a crop region then press submit.');
                  return false;
              };
  
          &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  &lt;!-- This is the image we're attaching Jcrop to --&gt;
          &lt;img src="demo_files/pool.jpg" id="cropbox" /&gt;
  
          &lt;!-- This is the form that our event handler fills --&gt;
          &lt;form action="crop.php" method="post" onsubmit="return checkCoords();"&gt;
              &lt;input type="hidden" id="x" name="x" /&gt;
              &lt;input type="hidden" id="y" name="y" /&gt;
              &lt;input type="hidden" id="w" name="w" /&gt;
              &lt;input type="hidden" id="h" name="h" /&gt;
              &lt;input type="submit" value="Crop Image" /&gt;
          &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The cropping is done perfectly and displayed the cropped image successfully.</p>
  
  <p>But i want to save the cropped image into a directory .</p>
  
  <p>How can i do this?</p>