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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:51:26+00:00 2026-05-26T06:51:26+00:00

The below is the runtime exeception which i got while am trying to upload

  • 0

The below is the runtime exeception which i got while am trying to upload a image to the server.
enter image description here

And am trying to upload a image using my local server(WAMP) and my android code is

Bitmap bitmap = BitmapFactory.decodeFile("/sdcard/Sunset.jpg");

     //   Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.background1); 
            ByteArrayOutputStream stream = new ByteArrayOutputStream();

            bitmap.compress(Bitmap.CompressFormat.PNG, 90, stream); //compress to which format you want.

            byte [] byte_arr = stream.toByteArray();
            String image_str = Base64.encodeBytes(byte_arr);

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

            try{

                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost("http://192.168.1.49/android/upload_image.php");

                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);

                String the_string_response = convertResponseToString(response);

                Toast.makeText(uploadimage.this, "Response  " + the_string_response, Toast.LENGTH_LONG).show();

            }catch(Exception e){
                  Toast.makeText(uploadimage.this, "ERROR " + e.getMessage(), Toast.LENGTH_LONG).show();

                  System.out.println("Error  http   connection"+e.toString());
            }

        }

        public String convertResponseToString(HttpResponse response) throws IllegalStateException, IOException{

             String res = "";
             StringBuffer buffer = new StringBuffer();

             inputStream = response.getEntity().getContent();
             int contentLength = (int) response.getEntity().getContentLength(); //getting content length…..

             Toast.makeText(uploadimage.this, "contentLength : " + contentLength, Toast.LENGTH_LONG).show();

             if (contentLength < 0){
             }
             else{
                    byte[] data = new byte[512];
                    int len = 0;

                    try
                    {
                        while (-1 != (len = inputStream.read(data)) )
                        {

                            buffer.append(new String(data, 0, len)); //converting to string and appending  to stringbuffer…..

                        }

                    }

                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }

                    try
                    {
                        inputStream.close(); // closing the stream…..
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }   
                     res = buffer.toString();     // converting string buffer to string

                    Toast.makeText(uploadimage.this, "Result : " + res, Toast.LENGTH_LONG).show();

                    //System.out.println("Response => " +  EntityUtils.toString(response.getEntity()));

             }
  return res;

        }

}

and this is my php code which i got from internet .

<?php

    $base=$_REQUEST['image'];

     $binary=base64_decode($base);

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

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

    fwrite($file, $binary);

    fclose($file);

    echo 'Image upload complete!!, Please check your php file directory……';

?>

Can any one help me in this to solve my problem. thanks in advance

  • 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-26T06:51:26+00:00Added an answer on May 26, 2026 at 6:51 am

    You have to create one additional directory in c:\ then provide read, write and execute permission on it.
    In your php code please write the absolute path of the storage location.

    This may solve your problem.

    Remember to run the IIS server in Administrator mode.

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

Sidebar

Related Questions

It is a compiler error or runtime error? The code below can be compiled!
I have code below which has been working on devices of type Windows Mobile
Below I have a very simple example of what I'm trying to do. I
Below is part of the XML which I am processing with PHP's XSLTProcessor :
Below is the code of a simple html with a table layout. In FF
We have a c# (3.5 framework) socket server which is a console app, after
Today I experienced a weird problem while trying to remotely debug an application built
I have an ASP.net project which involves using a custom IHttpModule. This module will
I am using tomcat as my webserver. i have application which needs a tomcat
I am using java message digest to create MD5 hash, which is used for

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.