Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8992627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:00:00+00:00 2026-06-15T23:00:00+00:00

So, to send an image to a web server i need to encode it

  • 0

So, to send an image to a web server i need to encode it to base64 and later decode on the server side.

This is what i am following.

But i get the OutOfMemoryException, at this line of code:

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

And the image size of 1mb. So, any alternate way to do this?

I read this:

Sending images using Http Post

which recommends to use MultipartEntity. But where exactly can i find those libraries? because 1 of the links is broken.

Code:

Uri selectedImageUri = data.getData();
String selectedImagePath = getPath(selectedImageUri);

try {
    File imageFile = new File(selectedImagePath);
    Bitmap bitmap = BitmapFactory.decodeFile(imageFile
            .getAbsolutePath());
    setImage.setImageBitmap(bitmap);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
    byte[] b = baos.toByteArray();
    base64code = Base64.encodeToString(b, Base64.DEFAULT);
    } catch (Exception e) {

    e.printStackTrace();
    }

Probably 1 way might be to reduce the quality. But if i set it to 20 or 30 and the image is already a low quality 1(taken from a low end device). I might get a bad quality image.

Doing something like check the size and reduce the quality depending on that. I don’t think is a good idea.

Thank You

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:00:02+00:00Added an answer on June 15, 2026 at 11:00 pm

    Upload images to server with MultipartEntity is one of the good option.

    MultipartEntity libraries Downloads :

    apache-mime4j-0.6.jar

    httpmime-4.0.1.jar

    Hope it helps you.

    Thanks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code http://stunningco.de/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/ to send an image to my web server
I need to send an image (as a downloadable file) from an ASP web
Hey, I'm currently trying to send an image file to a web server using
How to send a multiple image in sd card android to web server? Two
I want to send an image to a web server running .Net which is
I am need to convert image into hex string to send it to web
When i use one jpeg image with this web-server its very slow to show
I'm trying to send an image as a Base64 encoded string to my PHP
i'm using MFMailComposer to send an image.m using this code MFMailComposeViewController *picker = [[MFMailComposeViewController
Ok so i download a image and send the input stream to this method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.