Hi
I am trying to upload from a form using a high resolution photo (print quality photo), and wants generate a second smaller image.
But i am not getting the resized photo uploaded with this function i am using .
Where do i am wrong?
<?
//the function
function resize_jpg($img,$w,$h) {
$imagedata = getimagesize($img);
if ($w && ( $imagedata[0] < $imagedata[1] ) ) {
$w = ( $h / $imagedata[1]) $imagedata[0];
} else {
$h = ( $w / $imagedata[0]) $imagedata[1];
}
$im2 = ImageCreateTrueColor( $w,$h );
$image = ImageCreateFromJpeg( $img );
imagecopyResampled ( $im2, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1] );
$final_img = ImageJpeg( $im2, $img, 100 );
return $final_img;
}
//smallphoto name to the database,
//coming from the high res. photo
$link1 = "small".$FILES['photo_high_res']['name'];
//high res. photo name to the db
$link2 = $_FILES['photo_high_res']['name'];
//upload it
$y = move_uploaded_file($FILES['photo_high_res']['tmp_name'], $uploaddir . $FILES['photo_high_res']['name']);
//upload smaller photo using the function
//is it ok???
resize_jpg($FILES['photo_high_res']['tmp_name'],100,100);
resize_jpg($FILES['photo_high_res']['name'],100,100);
$x = move_uploaded_file("menor".$FILES['photo_high_res']['tmp_name'], $uploaddir . "small".$FILES['photo_high_res']['name']);
$rs = mysql_query("INSERT INTO photo (photo,photo_high_res,legend,desc_photo,date) values ('$link1','$link2','$legend','$desc_photo','$date')",$conn);
?>