我前几天发过帖子 Pass MySQL medium blob into IOS NSData\UIImage 但尚未找到解决方案。我的具体问题是,当我从数据库、blob 或文本检索图像时,它返回 NULL,其中没有变量的行只返回空白
while ($row = mysql_fetch_array($result)) {
$add = array();
$add["Id"] = $row["Id"];
$add["Mail"] = $row["Mail"];
$add["Category"] = $row["Category"];
$add["Phone"] = $row["Phone"];
$add["Msgs"] = $row["Msgs"];
//image from blob
$add["Picture"] = $row["Picture"];
// push single add into final response array
array_push($response["adds"], $add);
}
还有其他方法可以处理 blob\text 中的图像吗?!我试过https://stackoverflow.com/a/6273415/1333294但对我来说没有任何作用。
最佳答案
终于!!
$img = $row["Picture"];
$b64img = base64_encode ($img);
$b64img = mysql_real_escape_string($b64img);
$add["Picture"] = $b64img;
就这么简单! xcode 将其获取为 base64 字符串,并将其设为 NULL。感谢您的建议...
关于php - MySQL 中的 blob\text 图像返回 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16036071/