Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

imagecopyresampled then upload

upload an image, crop then upload result

4:12 pm on Jan 9, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:June 7, 2007
votes: 0

Happy New Year everyone.

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" />

That gets sent to this page:

$targ_w = $targ_h = 150;
$jpeg_quality = 90;

$src = $_POST['img'];
$img_r = imagecreatefromjpeg($src);
$dst_r = imagecreatetruecolor( $targ_w, $targ_h );


header('Content-type: image/jpeg');



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.


9:11 pm on Jan 17, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
votes: 0

How you doing with this? Not sure about the black square but to save the image you have to do just that, save it (write it) to a file in the place you want.