i want to upload image using MultipartEntityBuilder through httpost but it's not uploading.
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("firstName", firstname);
builder.addTextBody("lastName", lastname);
if (picture.length()>0) {
builder.addPart("picture", new FileBody(new File(picture)));
}
Log.d("URL", url);
String credentials = Base64.encodeToString((username+":"+password).getBytes(), Base64.NO_WRAP);
httpPost.setHeader("Authorization", "Basic "+credentials);
httpPost.setHeader("Content-type", "multipart/form-data");
Log.d("BasicAuthorization", credentials);
httpPost.setEntity(builder.build());
Please kindly go through my code and suggest me some solution.
Try this