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

  • Home
  • SEARCH
  • 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 6738393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:21:48+00:00 2026-05-26T11:21:48+00:00

I am sending an image from android phone to the server which hanldes it

  • 0

I am sending an image from android phone to the server which hanldes it ,but now i am confused on how to use the image in the server

my code for android phone which sends the image is

                            Log.i("sAMPLE","Info:" );
                //String postURL = HOST_SERVER_URL + HOST_PHOTO_UPLOAD_URI;
                String postURL ="http://10.0.2.2:8080/SimpleServlet/simple-servlet";//server URL
                HttpClient httpClient = new DefaultHttpClient();
                HttpPost postRequest = new HttpPost(postURL);

                ByteArrayBody bab = new ByteArrayBody(imageBytes, "file_name_ignored");
                MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                reqEntity.addPart("source", bab);
                postRequest.setEntity(reqEntity);

                HttpResponse response = httpClient.execute(postRequest); 

and my code which handles the image in the server is like this

        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
    boolean isMultipart = ServletFileUpload.isMultipartContent(req);
    System.out.println("Before Mutlipart");
    if(!isMultipart)
        throw new ServletException("upload using multipart");

    ServletFileUpload upload = new ServletFileUpload(fif);
    upload.setSizeMax(1024 * 1024 * 10 /* 10 mb */);
    List<FileItem> items;
    try {
        items = upload.parseRequest(req);
    //}// catch (FileUploadException e) {
      //  throw new ServletException(e);
    } catch (FileUploadException e) {
        // TODO Auto-generated catch block
        throw new ServletException(e);
    }

    if(items == null || items.size() == 0)
        throw new ServletException("No items uploaded");

    FileItem item = items.get(0);
    //BufferedImage Img=item.getString();
    System.out.println(item.getContentType());
    byte[]data=item.get();

now how do i use the byte array to display the image on the server or use to edit the image with some other stuffs like string,other image etc.

  • 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-05-26T11:21:48+00:00Added an answer on May 26, 2026 at 11:21 am

    I think this should work for you…

    http://www.mkyong.com/java/how-to-convert-byte-to-bufferedimage-in-java/

    on the server side (imageInByte is your data[])…

    //convert byte array back to BufferedImage
    InputStream in = new ByteArrayInputStream(imageInByte);
    BufferedImage bImageFromConvert = ImageIO.read(in);
    
    ImageIO.write(bImageFromConvert, "jpg", 
             new File("c:\\image\\mypic_new.jpg")); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending a image from android phone to server which is a servlet
Example: <div id=sampleimage> ***Stream or Serialize JPEG Image from Server Here w/o Sending another
Im trying to read in image file from a server , with the code
sending mail along with embedded image using asp.net I have already used following but
M sending the parameters from the jsp page, the code is <s:url id=url action=searchAction>
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I
What I'm doing I'm pulling an image from the database and sending it to
I'm following from an example of sending an email with image attachment through mail().
I'm sending an image file from an iPhone application to a http Post application.
I'm a C# beginner facing problems regarding sending an image from a client to

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.