I am trying to upload an image to server.For that I have added jar files like apache-mime4j,http client,httpcore and httpmime.
And my code is as follows..
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
MultipartEntity multiPart = new MultipartEntity();
multiPart.addPart("my_picture", new FileBody(new File(imagePath.toString())));
httpPost.setEntity(multiPart);
HttpResponse res = httpClient.execute(httpPost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String json = reader.readLine();
JSONTokener tokener = new JSONTokener(json);
JSONObject object = (JSONObject) new JSONTokener(json).nextValue();
JSONArray data = object.getJSONArray("data");
System.out.println("posted finalResult"+data);
if (responseEntity != null) {
responseEntity.consumeContent();
}
httpclient.getConnectionManager().shutdown();
The problem is that I am getting an error at the line
multiPart.addPart("my_picture", new FileBody(new File(imagePath.toString())));
And on clicking that error I am getting "Configure build path".
Anyone please tell me what is wrong in my code.
Thanx in advance.