我正在尝试使用multipartentity在php服务器上传图片,我使用httpmime 4.3 jar导入多部分实体,我已将此jar添加到我的应用程序中,但我无法导入此类。
public void postPicture(String path, File file) throws ParseException,
IOException {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(
CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
HttpPost httppost = new HttpPost(path);
MultipartEntity mpEntity = new MultipartEntity();
FileBody cbFile = new FileBody(file, "image/png");
cbFile.getMediaType();
mpEntity.addPart("userfile", cbFile);
httppost.setEntity(mpEntity);
HttpResponse response = httpclient.execute(httppost);
}
任何人都可以帮助我。提前谢谢。