I have a MySQL table set up with two BLOB fields, one which stores a
full-size jpeg, and one which stores a thumbnail of it. I am trying to
create a PHP script that will resize the full-size image and insert it
into the thumbnail field. The resizing part was easy, and now I have
an Image resource in memory. How do I insert this binary data into the
BLOB field?
I do not want to use Base64 encoding, nor do I want to use an HTML
upload form - the data must be inserted from the variable I already
have ($imaged), and it must be inserted in raw form, without
additional encoding. I have come across answers regarding the use of
'addslashes' but this has not helped. The following is the most recent
query I tried.
$query = "INSERT INTO photos (thumbnail) values('" .
addslashes(imagejpeg($imaged, null, 100)) . "')"; |