I have created an app in which user select an image from gallery and that image is uploaded to the server.I tried doing it using Httprequest Library.But i m not being able to up
Try This code and this library add httpmime-4.1-beta1.jar :
String url = "Your Url";
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(
CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpPost postMethod = new HttpPost(url);
MultipartEntity entity = new MultipartEntity();
entity.addPart("fname", new StringBody("xyz"));
try {
File file1 = new File("Your image Path");
FileBody bin1 = new FileBody(file1, "images/jpeg");
entity.addPart("file", bin1);
postMethod.setEntity(entity);
HttpResponse response;
response = client.execute(postMethod);
String result = EntityUtils.toString(response.getEntity());
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}