homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

imagecopyresampled then upload
upload an image, crop then upload result
Robert Poole

 4:12 pm on Jan 9, 2009 (gmt 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)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved