Wrong result when using imagecopyresized
Posted: Mon Jun 28, 2004 5:25 pm
Hey guys:
I have the following code:
It is supposed to take an uploaded image, resize it, and then return that image to the variable $logoimage (so that I can save it in a BLOB in a database).
However, what happens when I try to INSERT $logoimage using the following code is, instead of the JPG, I get "Resource id #5":
$query = "INSERT INTO `table` SET `logo` = '$logoimage' WHERE `id` = '555' LIMIT 1;";
I think I am not referring to $logoimage properly. I assume the resizeImage function works properly (I modified something I found elsewhere), but I can't really test it until I can properly insert the JPG into the database.
Any ideas?
Thanks,
Peter.
I have the following code:
Code: Select all
<?php
$logoimage = resizeImage($_FILES["photo"]["tmp_name"], 100, 100, 50);
function resizeImage($srcfile, $width, $height, $compression) {
$dst_img = imagecreate($width,$height);
$src_img = imagecreatefromJPEG("$srcfile");
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $width, $height, imagesx($src_img), imagesy($src_img));
return($dst_img);
}
?>However, what happens when I try to INSERT $logoimage using the following code is, instead of the JPG, I get "Resource id #5":
$query = "INSERT INTO `table` SET `logo` = '$logoimage' WHERE `id` = '555' LIMIT 1;";
I think I am not referring to $logoimage properly. I assume the resizeImage function works properly (I modified something I found elsewhere), but I can't really test it until I can properly insert the JPG into the database.
Any ideas?
Thanks,
Peter.