Hi, I generate a thumbnail using GD and php, but now I want to store the resulting image in mysql. I have a field called imgbg which is a blob type, but when I make the update query, it insert a text saying "resource id#5" something like that?.
can you guys show another way ?
this is part of my code:
$tao = $POST['user'];
$smallPic = $FILES['smallPic'];
$image_type = $FILES['smallPic']['type'];
$image_type2 = $FILES['smallPic']['tmp_name'];
$sizer = $_FILES['smallPic']['size'];
$fileHandle = fopen($image_type2, "r");
$fileContent = fread($fileHandle, $sizer);
$fileContent = addslashes($fileContent);
$nw=80; //The Width Of The Thumbnails
$nh=80; //The Height Of The Thumbnails
$ipath = "/img/temp";
$img = $image_type2;
$dimensions = GetImageSize($img);
$thname = "img/temp/thumb". $tao .".jpg";
$w=$dimensions[0];
$h=$dimensions[1];
$img2 = ImageCreateFromJpeg($img);
$thumb = ImageCreateTrueColor($nw,$nh);
$wm = $w/$nw;
$hm = $h/$nh;
$h_height = $nh/2;
$w_height = $nw/2;
if($w > $h){
$adjusted_width = $w / $hm;
$half_width = $adjusted_width / 2;
$int_width = $half_width - $w_height;
ImageCopyResampled($thumb,$img2,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h);
ImageJPEG($thumb,$thname,95);
}elseif(($w < $h) || ($w == $h)){
$adjusted_height = $h / $wm;
$half_height = $adjusted_height / 2;
$int_height = $half_height - $h_height;
ImageCopyResampled($thumb,$img2,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h);
ImageJPEG($thumb,$thname,95);
}else{
ImageCopyResampled($thumb,$img2,0,0,0,0,$nw,$nh,$w,$h);
ImageJPEG($thumb,$thname,95);
}
imagedestroy($img2);
$Query = "UPDATE profile SET imgbg = '$img2' type = '$image_type' WHERE Id = '$tao'";
mysql_select_db($database_cs, $cs);
mysql_query($Query);
can you guys show another way ?