Php 使用json将图像blob数据获取到android应用程序
我必须在我的android应用程序中显示一些来自外部数据库(包括图像)的数据。我已成功地从数据库中获取文本数据。这是我的php代码。现在我需要获取blob数据。我怎样才能做到这一点Php 使用json将图像blob数据获取到android应用程序,php,android,json,blob,Php,Android,Json,Blob,我必须在我的android应用程序中显示一些来自外部数据库(包括图像)的数据。我已成功地从数据库中获取文本数据。这是我的php代码。现在我需要获取blob数据。我怎样才能做到这一点 $id=$_POST['ID']; $db_server = mysql_connect($hostname,$username,$password); if (!$db_server) die("Unable to connect to MySQL: " . mysql_error()); mysql_sel
$id=$_POST['ID'];
$db_server = mysql_connect($hostname,$username,$password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($database,$db_server);
$result=mysql_query("select * from names where ID=$id");
while($row=mysql_fetch_assoc($result)){
$output[]=$row;
}
print(json_encode($output));
mysql_close($db_server);
?>不建议在json中传递blob数据,请使用该图像的url来传递响应。图像位于数据库中。我认为每个图像都没有唯一的url。这就是我要说的,不要为了更好的性能而将图像保存在数据库中。但是如果你想以同样的方式发送,你必须以字节的形式发送。你知道如何以字节的形式发送图像吗?请参考和