0
如何上传图像(作为字节数组)到服务器使用web服务,在Android?任何人都可以帮助我上传图像到服务器
如何上传图像(作为字节数组)到服务器使用web服务,在Android?任何人都可以帮助我上传图像到服务器
对于soap webservices,您可以使用ksoap2。还有一个wsdl> proxy.java生成器
**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);