【问题标题】:Can anyone help me to upload an image to server谁能帮我把图片上传到服务器
【发布时间】:2011-09-07 10:54:45
【问题描述】:

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

【问题讨论】:

    标签: android image upload byte


    【解决方案1】:

    对于肥皂网络服务,您可以使用 ksoap2。还有一个 wsdl>proxy.java 生成器

    【讨论】:

      【解决方案2】:
      **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);
      

      【讨论】:

        猜你喜欢
        • 2019-11-19
        • 1970-01-01
        • 2012-12-18
        • 2011-06-01
        相关资源
        最近更新 更多