Forum Moderators: coopster
Okay, so here's my dilemma of the day. I'm using a jQuery image crop feature, and what I want to do is upload an image, crop it, then take the result and upload that (then delete the original).
I have no problems uploading the original picture to a temporary folder "temp" and the preview all looks fine, and under that sits this form:
<form action="upload.php" method="post" onSubmit="return checkCoords();">
<input type="hidden" id="img" name="img" value="<?php echo $path_name; ?>" />
<input type="hidden" id="x" name="x" />
<input type="hidden" id="y" name="y" />
<input type="hidden" id="w" name="w" />
<input type="hidden" id="h" name="h" />
<input type="submit" name="Crop" value="Crop Image" class="submit" />
</form>
That gets sent to this page:
<?php
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = $_POST['img'];
$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;
?>
But what I get is a 150x150 black square. That's problem #1. Problem #2 would be how do I upload the resulting 150x150 image?
Any help would be appreciated.
Roberto.