Skip to content Skip to sidebar Skip to footer

How To Upload Image In Base64 On Server

i have a problem, i am uploading image on server but it is not. i have convert image in base64 and get through json. but json is not properly closed due to this i m getting error.

Solution 1:

String encodedImageData =getEncoded64ImageStringFromBitmap(your bitmap);

public String getEncoded64ImageStringFromBitmap(Bitmap bitmap) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(CompressFormat.JPEG, 70, stream);
    byte[] byteFormat = stream.toByteArray();
    // get the base 64 string
    String imgString = Base64.encodeToString(byteFormat, Base64.NO_WRAP);

    return imgString;
}

Post a Comment for "How To Upload Image In Base64 On Server"