当我尝试上传文件时,我添加了httpmime-4.0.1 jar文件.. 我发现包裹申报行有错误。我可以清楚这个,
错误
*此行的多个标记
-the type org.apache.james.mime4j.message.singlebody cannot be resolves , It is indirectly refrenced fron required .class files*
我的代码。
public void uploading() {
//Url of the server
String url = "http://192.168.1.125/ui-design1/newremote/sendgisttoall";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
MultipartEntity mpEntity = new MultipartEntity();
//Path of the file to be uploaded
File file = new File(filePath);
ContentBody cbFile = new FileBody(file);
//Add the data to the multipart entity
mpEntity.addPart("gistimage", cbFile);
mpEntity.addPart("token", new StringBody(token, Charset.forName("UTF-8")));
post.setEntity(mpEntity);
HttpResponse response1 = client.execute(post);
HttpEntity resEntity = response1.getEntity();
String Response=EntityUtils.toString(resEntity);
Log.d("Response:", Response);