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 8642433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:46:29+00:00 2026-06-12T11:46:29+00:00

I have written a Android program to upload a file to server by HTTP

  • 0

I have written a Android program to upload a file to server by HTTP POST.

Earlier its was working fine but I don’t know why it is not working now.
I am testing this with my Android Device.
I Have just checked that It is working fine with emulator.

When I open that link in browser, Then it is still working fine and open correctly.

Do any body can tell me what could be the problem???

I am getting this error: (No Address associated with hostname)

 10-07 04:28:14.410: I/System.out(1280): executing request POST http:////path/to/my/server//api/index.php/match HTTP/1.1
10-07 04:28:14.450: W/System.err(1280): java.net.UnknownHostException: Unable to resolve host "//path/to/my/server/": No address associated with hostname

Here is my code…

private class UploadFilesTask extends AsyncTask<File, Void, Void> {
        @Override
        protected Void doInBackground(File... arg0) {

             HttpClient httpclient = new DefaultHttpClient();
                httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
enter code here
                    // I have not shown my REAL server address due so some restriction, So assume below URL is correct

                HttpPost httppost = new HttpPost("http://path/to/my/server/"); //Assume path is correct
                //File file = new File("/mnt/sdcard/DCIM/Camera/01.jpg");

                MultipartEntity mpEntity = new MultipartEntity();
                ContentBody cbFile = new FileBody(arg0[0], "image/jpeg");
                mpEntity.addPart("userfile", cbFile);


                httppost.setEntity(mpEntity);
                System.out.println("executing request " + httppost.getRequestLine());
                HttpResponse response = null;
                try {
                    response = httpclient.execute(httppost);
                } catch (ClientProtocolException e) {
                    // TODO Auto-generated catch block

                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block

                    e.printStackTrace();
                }
                HttpEntity resEntity = response.getEntity();

                System.out.println(response.getStatusLine());
                if (resEntity != null) {
                  try {
                      //audioFilename = EntityUtils.toString(resEntity);
                      System.out.println(EntityUtils.toString(resEntity));
                } catch (ParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                }
                if (resEntity != null) {
                  try {
                    resEntity.consumeContent();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                }

                httpclient.getConnectionManager().shutdown();
                return null;
        }
    }
  • 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-12T11:46:30+00:00Added an answer on June 12, 2026 at 11:46 am

    Try the following

    1. Delete your AVD
    2. Shut down Eclipse
    3. Created the AVD via the command line (e.g. android create avd -n my_android1.5 -t 2)
    4. Launched it from the command line with the option -dns-server 8.8.8.8 (e.g. emulator -avd my_android1.5 -dns-server 8.8.8.8)

    p.s. Make sure you didn’t delete the internet permission in your manifest file by accident. Also, while you are it, check and make sure the address work on your android browser.

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

Sidebar

Related Questions

I have written a simple database program in android. It runs fine, there is
I have written program in android for downloading from web server I have Used
I am writing an Android App, and already have a working program written in
I have written an Android application that I am about to release, but I
I have written a socket listener program for Android. In my program, I create
I have the following method for my android program, written in Java. The method
I am new to android and I have written a program that displays the
Have written Geolocation API code for android and iphone. Take reference from http://dev.w3.org/geo/api/spec-source.html .
I had written a program (In Android, client side and PHP, server side) to
I have an android program, written in Java and it uses a Wifi Hotspot,

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.