I did see a few posts up here that have similar issues and I tried a few of the answers but nothing really works for me.
public function upload_image3($post_array,$primary_key)
{
$szFile=str_replace("/files/","/thumbnails/",$post_array['thumbnail_url']);
$file_types = array( ".doc", ".ppt", ".pdf", ".xls", ".jpg");
$szFile=str_replace($file_types,".png",$szFile);
$szFile3 = file_get_contents($szFile);
$imgData = addslashes($szFile3);
$BLOB_insert = array(
"id" => $primary_key,
"image_BLOB" => $imgData
);
$iRc=$this->db->update($_SESSION[table],$BLOB_insert);
return;
}
I have an image locally on my drive and it arrives via the $post_array. I am trying to save it in a BLOB field in my RDS mysql table. My code is above. I have both the original file (doc or ppt or xls) and I also has a thumbnail of it (same name, just ending in .png) and in the /thumbnails dir. Everything works fine until the update. The return code from the update is NULL. And then when I look in the table with mysqlWorkBench, it appears to still be NULL. So the update is not working and I don't know why or where to look for an error code.
In viewing the local error.log I see that I got the following error:
Query error: Invalid utf8 character string: '\x89PNG' - Invalid query: UPDATE substantiator
.word
SET image_BLOB = �PNG
This makes me think that the default collation was not setup correctly for the USA. I am thinking that if I can modify the default collation (and maybe recreate the BLOB columns) then perhaps this will work. But how to do that on RDS?