I hope this will help you..
*You need to get
httpcomponents-client-4.1.zip and apache-mime4j-0.6.1-bin.zip
Add
apache-mime4j-0.6.1-bin.zip
and
httpclient-4.1.jar
httpcore-4.1.jar
httpmime-4.1.jar
from the lib folder in httpcomponents-client-4.1.zip
- See more at: http://blog.tacticalnuclearstrike.com/2010/01/using-multipartentity-in-android-applications/#sthash.N7qT8apH.dpuf*
try {
MultipartEntity multipart = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
FormBodyPart office = new FormBodyPart("office",
new StringBody(getOffice));
multipart.addPart(office);
String imageCount = Integer.toString(drawableList.size());
System.out.println("ImageCount : " + imageCount);
FormBodyPart imgNo = new FormBodyPart("imgNo", new StringBody(
imageCount));
multipart.addPart(imgNo);
} catch (Exception e) {
// TODO: handle exception
}
try {
System.out.println("result : " + multipart.getContentLength());
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(CommunicatorUrl.ADD_INCIDENT);
httppost.setEntity(multipart);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
// print responce
outPut = EntityUtils.toString(entity);
} catch (Exception e) {
Log.e("log_tag ******",
"Error in http connection " + e.toString());
}
basically this MultipartEntity is useful for sending multiple images and datas to server using post method