Page 1 of 1

Help Created thumbnail then can't save to blob!

Posted: Mon Mar 23, 2009 8:13 pm
by wizard0356
I have a working on a PHP script that allows me to upload an image and then resizes that image and outputs it to the browser. I would like to alter the script so that instead of outputting the thumb to the browser, it saves it in a MySQL table field of MEDIUM BLOB type.

But I am at a loss how to do this. I have RTFM more times than I can count! The last few lines of code I now have actually save the thumbnail to a local directory on the server

imagejpeg( $tmp_img, "$thumbpath" );

I have already tried

ob_start();
imagejpeg($tmp_img);
$bthumb = ob_get_contents();
ob_end_clean();

$dbquery = "INSERT INTO image(small, large, description)";
$dbquery .= " VALUES ('$bthumb', '$fileContent','$photoname')";
mysql_query($dbquery) or die("Couldn't add file to database");

the issue is the $bthumb -- the query inserts the large image and the description if I remove the small one which is the $bthumb. Any help would be much appreciated!