title: Save Crop image in php
body: <p>I crop image using <code>imagecopy</code>  in php. but I want save it to my old path. what can I used for it ? this is my method how i crop the image .</p>
  
  <pre><code>$w=250;
      $h=300;    
      $x=$_POST['x1'];    
      $y=$_POST['y1'];   
      $filename="upload/".$_SESSION['basename'];
      header('Content-type: image/jpg');
      //header('Content-Disposition: attachment; filename='.$src);
      $image = imagecreatefromjpeg($filename);
      $crop = imagecreatetruecolor($w,$h);
      $new = imagecopy ($crop, $image, 0, 0, $x, $y, $w, $h);
      imagejpeg($crop);
      imagedestroy($filename);
  </code></pre>
  
  <p>I used this method, but it was not work for me.</p>
  
  <pre><code>$input = 'upload/'.$new;
      $output = 'upload/xxx.jpg';
      file_put_contents($output, file_get_contents($input));
  </code></pre>