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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:15:39+00:00 2026-06-06T15:15:39+00:00

I am uploading in android. To do so I am following this tutorial .

  • 0

I am uploading in android. To do so I am following this tutorial. My current code gives me this error in my logcat

06-23 10:10:22.990: D/dalvikvm(25853): GC_EXTERNAL_ALLOC freed 48K, 50% free 2723K/5379K, external 0K/0K, paused 33ms
06-23 10:10:23.030: E/log_tag(25853): Error in http connection java.net.UnknownHostException: www.example.info
06-23 10:10:23.115: D/CLIPBOARD(25853): Hide Clipboard dialog at Starting input: finished by someone else... !

Here is how my code looks like

public class UploadFileActivity extends Activity {
/** Called when the activity is first created. */
Button bUpload;
EditText etParam;

InputStream is;

@Override

public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    setContentView(R.layout.main);

    Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 90, bao);

    byte [] ba = bao.toByteArray();
    String ba1=Base64.encodeToString(ba, 0);

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("image",ba1));

    try {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://www.example.info/androidfileupload/index.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
    } catch(Exception e) {
        Log.e("log_tag", "Error in http connection "+e.toString());
    }

}
}

Here is what I am using on the server side

<?php
$base=$_REQUEST['image'];

echo $base;

// base64 encoded utf-8 string

$binary=base64_decode($base);

// binary, utf-8 bytes

header('Content-Type: bitmap; charset=utf-8');

// print($binary);

//$theFile = base64_decode($image_data);

$file = fopen('test.jpg', 'wb');

fwrite($file, $binary);

fclose($file);

echo '<img src=test.jpg>';

?>
  • 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-06T15:15:42+00:00Added an answer on June 6, 2026 at 3:15 pm

    The UnknownHostException is related to your url domain or there is no Internet/Network connectivity,

    So make sure you have added Internet permission in your AndroidManifest file.

    <uses-permission android:name="android.permission.INTERNET" />
    

    Hope This Helps

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

Sidebar

Related Questions

I tried the following code with android 2.3.3 (AVD). When i run this code
I am facing the following issue while uploading the video from my android application.
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
When I'm uploading a module to Hackage, I get the following error message: Exposed
New Android developer here. I'm following a tutorial at http://www.vogella.de/ . The first applications
I continue to get this as I'm uploading my Android app information, screen shots,
When I try uploading the APK to the Android Market, I get this message:
When i am uploading my application in android market it showing below error The
The following is a snippet for uploading files using PHP. I am an Android
I changed some code on an android application that was working perfectly fine at

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.