繁体   English   中英

将Base64字符串转换为图像(使用JSON从android发送),并使用PHP在MySQL中另存为BLOB

[英]Convert Base64 String to Image (which sent from android using JSON) and save as BLOB in MySQL using PHP

实际上,我已经从android项目中的JSON获取了图像字符串。 字符串图像成功传递给使用HTTPPOST。 现在,我面临在php的mysql数据库中将图像保存为blob类型的问题。 如何转换我得到的字符串图像,以便可以将其保存为mysql数据库中的blob类型? 如果有人知道方法,请指教。

谢谢。

只是base64_decode()数据:

$blob = base64_decode($json_64_encoded_string);

然后将其写入数据库。 如果您需要帮助将编码后的字符串从POST数组中取出,请查看PHP json_decode函数: http : json_decode

$json_obj = json_decode($_POST[post_key]); //replace 'post_key' with whatever you use
$blob = base64_decode($json_obj->blob); //replace 'blob' with whatever you use

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM