如何为HttpClient发布文件和字符串?

时间:2011-09-20 09:04:24

标签: android string file post httpclient

我使用打击代码,发布文件和字符串,但响应错误代码为500。

Uri.Builder builder = new Uri.Builder();
              builder.path(AIRQ_POST_AIRQ);
              HttpPost post = new HttpPost(builder.build().toString());

              FileEntity imageEntity=new FileEntity(null,"multipart/form-data");

              StringEntity msgEntity = new StringEntity(msg,CharEncoding.UTF_8);
              StringEntity latEntity = new StringEntity(""+lat,CharEncoding.UTF_8);
              StringEntity lonEntity = new StringEntity(""+lon,CharEncoding.UTF_8);
              StringEntity typeEntity = new StringEntity(""+type,CharEncoding.UTF_8);
              StringEntity tagidEntity = new StringEntity(""+tagid,CharEncoding.UTF_8);
              StringEntity sourceEntity = new StringEntity(source,CharEncoding.UTF_8);

              post.setEntity(imageEntity);
              post.setEntity(msgEntity);
              post.setEntity(latEntity);
              post.setEntity(lonEntity);
              post.setEntity(typeEntity);
              post.setEntity(tagidEntity);
              post.setEntity(sourceEntity);

              sendAirQHttpTask(post,responseHandler);

1 个答案:

答案 0 :(得分:1)

问题出在服务器端。正如您所看到的,here 500表示Internal Server Error