Android的:如何使用PHP MySQL中上传图片 [英] Android: how to upload image in mysql using php
本文介绍了Android的:如何使用PHP MySQL中上传图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有图像中由用户选择的ImageView的......怎么可以使用PHP我将它插入到MySQL数据库中的表?
I have image in ImageView that is selected by the user ... how can i insert it to mysql database table using php?
谁能帮助我这一点。
这是我想要的图像,以节省其列的类型为BLOB。
the type of column that i want image to save on it is Blob.
推荐答案
OK,我发现我的问题的解决方案
OK that i found a solution for my question
code在java中假设图像已经转换为位图:
code in java assuming that the image is already converted to bitmap:
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmIcone.compress(Bitmap.CompressFormat.PNG, 90, stream);
byte[] byte_arr = stream.toByteArray();
String image_str = Base64.encodeBytes(byte_arr);
namevaluepair.add(new BasicNameValuePair("image", image_str));
在服务器:
$base= $_REQUEST['image'];
$buffer = base64_decode($base);
$buffer = mysql_real_escape_string($buffer);
然后插入$缓冲区表BLOB列类型
then inserting the $buffer to table blob column type
这篇关于Android的:如何使用PHP MySQL中上传图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文