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


Robert Poole

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

5+ Year Member

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)

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

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.

Featured Threads

Hot Threads This Week

Hot Threads This Month