我刚刚保存了一张图片(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 有 MEDIUMBLOB 类型)
然后尝试获取它(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;
请求show.php时,它给出了几乎相同的图像,但尺寸不同:136x94 =)
为什么会这样?