I'm currently trying to use the GD library to crop and upload an image. I upload the image first to the server and save the url to the image which I then pass to the following script which reads the original uploaded image and it crops it according to the coordinate that I give it.
<?php
$w = $h = 150;
$quality = 90;
$src = $_POST['path'];
$img = imagecreatefromjpeg($src);
$kak = ImageCreateTrueColor( $w, $h );
imagecopyresampled($kak,$img,0,0,$_POST['x'],$_POST['y'],
$w,$h,$_POST['w'],$_POST['h']);
header('Content-type: image/jpeg');
imagejpeg($kak,'c.jpg',$quality);
imagedestroy($img);
?>
All works fine, image upload, crop and cropped image upload. The problem is that this page is completely empty and I would like to redirect the visitor to a different page but if I add
header ("Location: nextpage.php");
at the end of my php script it obviously redirects before finishing uploading. Does anyone know how to do this once the file has been uploaded successfully?
Thanks in advance