任何人都可以帮我上传图像到服务器

时间:2011-09-07 10:54:45

标签: android image upload byte

如何在Android中使用网络服务将图像(作为字节数组)上传到服务器?

2 个答案:

答案 0 :(得分:0)

对于soap webservices,您可以使用kso​​ap2。还有一个wsdl> proxy.java生成器

答案 1 :(得分:0)

**To upload your Image to server, convert a bitmap image to base64 and then send the string. Use the below code**

Bitmap resizedBitmap = Bitmap.createBitmap(bmp, 0, 0, width,
                    height, matrix, true);
ByteArrayOutputStream baostream = new ByteArrayOutputStream();
resizedBitmap.compress(Bitmap.CompressFormat.PNG, 100, baostream);

byte[] byteArrays = baostream.toByteArray();
encode = Base64.encodeBytes(byteArrays);

**and vice-versa**

byte[] decode = Base64.decode(encode);
Bitmap bitmp = BitmapFactory.decodeByteArray(decode, 0,
                        decode.length);