Bug #40727 | Cannot open the jpg image saved in longblob data field | ||
---|---|---|---|
Submitted: | 14 Nov 2008 6:49 | Modified: | 15 Nov 2008 6:31 |
Reporter: | Yen Harn Chuah | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / ODBC | Severity: | S1 (Critical) |
Version: | 5.1 | OS: | Windows |
Assigned to: | CPU Architecture: | Any | |
Tags: | ADO, longblob, MySQL 5.0, ODBC |
[14 Nov 2008 6:49]
Yen Harn Chuah
[14 Nov 2008 7:01]
Yen Harn Chuah
Actually when the images are displayed on web, it seems work, but when use ADO + .Net + ODBC 3.51@5.1, the images can be saved but cannot be opened and viewed
[14 Nov 2008 17:06]
Jess Balint
Yen, Why do you base64 encode the image data before inserting it into the database? This doesn't make any sense. You should insert the raw data into the database.
[15 Nov 2008 3:20]
Yen Harn Chuah
$encoded = chunk_split(base64_encode($contents1)); This one is done by another developer, I have tried to change it be 1. $encoded = chunk_split($contents1); 2. $encoded = $contents1; but it have error when upload, any comments on it?
[15 Nov 2008 3:53]
Yen Harn Chuah
$query2 = "INSERT INTO tbl_userimginfo (image_name,ic,name,email,house_pno,office_pno,hp,card_type,upload_date,upload_time,app_status) values ('".$ic."','".$ic."','".$name."','".$email."','".$house."','".$office."','".$hp_all."','".$card_type."','".$upload_date."','".$upload_time."','".$app_status."')"; $rs2 = mysql_query($query2); if($rs2){ //open the copied image, ready to encode into text to go into the database $filename2 = "myimage/uploaded/".$image_link; // save with logo to DB $filename1 = "myimage/cropped/".$image_link; // save without logo to DB $fp1 = fopen($filename1, "r"); //record the image contents into a variable $contents1 = fread($fp1, filesize($filename1)); //close the file fclose($fp1); //encode the image into text //$encoded = chunk_split(base64_encode($contents1)); //$encoded = chunk_split($contents1); //insert image (in BLOB) into the database //$query3 = "UPDATE tbl_userimginfo SET image = '$encoded' WHERE image_name = '$ic' " ; $query3 = "UPDATE tbl_userimginfo SET image = '$contents1' WHERE image_name = '$ic' " ; $rs3 = mysql_query($query3); ** The image is not updated to the mySQL
[15 Nov 2008 4:09]
Yen Harn Chuah
solved, TQ //$encoded = chunk_split(base64_encode($contents1)); $encoded = mysql_real_escape_string($contents1);