uploading image to server
<p>code for uploading image to server : 
Entir code here</p>

<pre><code>static{
    httpclient=new DefaultHttpClient();
    httpPost=new HttpPost(serverUrl);
}

public String uploadImage(String imageFileURL){

    Bitmap bitmap=BitmapFactory.decodeFile(imageFileURL);
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 90, baos);
    byte []ba=baos.toByteArray();
    String bal=Base64.encodeBytes(ba);
    ArrayList&lt;NameValuePair&gt; nameValuePair=new ArrayList&lt;NameValuePair&gt;();
    nameValuePair.add(new BasicNameValuePair("image",bal));
     String res = "";
     StringBuffer buffer = new StringBuffer();
    try {
        httpPost.setEntity(new UrlEncodedFormEntity(nameValuePair));
        httpresponse=httpclient.execute(httpPost);
        httpEntity=httpresponse.getEntity();
        inputStream=httpresponse.getEntity().getContent();

        int contentLength=(int) httpresponse.getEntity().getContentLength();
        if(contentLength&lt;0){

        }
        else{
            byte []data =new byte[512];
            int len=0;
            try{
                while(-1 !=(len=inputStream.read(data))){
                    buffer.append(new String(data,0,len));
                }

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

    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    finally{
        try {
            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    res=buffer.toString();
    return res; 
}
</code></pre>

<p>this method is being called on the </p>

<pre><code> onClick(View view){
    new Thread(new Runnable(){

        public void run() {
            // TODO Auto-generated method stub
            response=new ServerCommunication().uploadImage(path);
        }           
    }).start();
</code></pre>

<p>but it is showing as <code>TimeOutException</code>. Can any one tell what I am doing wrong.</p>
