Welcome Guest, Not a member yet? Register   Sign In
uploading an image (BLOB) to mysql
#5

(This post was last modified: 03-20-2021, 12:15 PM by richb201.)

(03-20-2021, 11:34 AM)InsiteFX Wrote: Because you are inserting it  wrong.

Look at this code.

PHP Code:
$products[] = [
    'product_name' => 'MySQL DATABASES',
    'price' => 15,
    'product_image' => file_get_contents("https://i.imgur.com/UYcHkKD.png" )
]; 

You assign the contents to the image not png.

This is being called after the record has been inserted, and that is why it is update rather than insert. 

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;
}



$iRc is returning null so i don't know if this is succeeding. I then tried SELECT HEX(image_BLOB) FROM word where id=17 in mysqlWorkbench and the BLOB appears blank.
proof that an old dog can learn new tricks
Reply


Messages In This Thread
uploading an image (BLOB) to mysql - by richb201 - 03-19-2021, 09:04 AM
RE: uploading an image (BLOB) to mysql - by richb201 - 03-20-2021, 11:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB