I've just saved an image (PNG, 200x209)
$img = chunk_split(base64_encode(file_get_contents("image.png")));
$sql = "INSERT INTO table (img) VALUES ('$img') WHERE userid = 10";
mysql_query($sql);
(img has a MEDIUMBLOB type)
then trying to obtain it (show.php):
header("Content-type: image/jpeg");
$sql = "SELECT img FROM table WHERE userid = 10 LIMIT 1";
$res = mysql_query($sql);
while ($row = mysql_fetch_assoc($res)) {
$image = base64_decode($row['img']);
}
echo $image;
when requesting show.php it gives almost the same image, but with another dimension: 136x94 =)
Why that happens?
BINARY LARGE OBJECTand can directly handle the .png file as is.