title: Uploading an image to server in android without changing in multipart form
body: <p>In my app i am trying to upload an image on grails server, problem is that converting the image into base 64 format is not getting accepted at the back end, server developer says it should not be in multipart form. <br>Here is my code:</p>
  
  <pre><code>     ArrayList&lt;NameValuePair&gt; nameValuePairs = new  ArrayList&lt;NameValuePair&gt;();
       Bitmap bitmap = BitmapFactory.decodeFile(imagePath);           
  
       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.encodeToString(byte_arr,Base64.DEFAULT);
  
       nameValuePairs.add(new BasicNameValuePair("fileupload",image_str));
  
  
       nameValuePairs.add(new BasicNameValuePair("message", "trial"));
  
       try{
           HttpClient httpclient = new DefaultHttpClient();
           HttpPost httppost = new HttpPost(serverURL);
           httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
           HttpResponse response = httpclient.execute(httppost);
           Log.i(TAG, " http reponse is:" +response);
           convertResponseToString(response);
       }catch(Exception e){
             System.out.println("Error in http connection "+e.toString());
       } 
  </code></pre>