![](/img/trans.png)
[英]How to upload a captured image with android device to mysql database using php?
[英]Android: how to upload image in mysql using php
我在ImageView中有用户选择的图像...我如何使用php将其插入到mysql数据库表中?
谁能帮助我。
我要图像保存在其上的列的类型是Blob。
好,我找到了解决我问题的方法
假定图像已转换为位图的Java代码:
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);
然后将$ buffer插入表Blob列类型
首先,您将不得不在android中调用您的php。 关于此主题的许多答案已经存在:
为了回答您的问题,本教程教您如何编写php在MySQL中存储图像:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.