0

我尝试下载 [httpmime-4.0.1.jar] 但仍然存在错误并且 ------------------------------ -

类 ImageUploadTask 扩展 AsyncTask { @Override

    protected String doInBackground(Void... unsued) {

        try {

            HttpClient httpClient = new DefaultHttpClient();





HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost(getString(R.string.WebServiceURL) + "/cfc/iphonewebservice.cfc?method=uploadPhoto");
            MultipartEntity entity = new MultipartEntity(

         HttpMultipartMode.BROWSER_COMPATIBLE);





ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bitmap.compress(CompressFormat.JPEG, 100, bos);
            byte[] data = bos.toByteArray();
            entity.addPart("photoId", new StringBody(getIntent()



.getStringExtra("photoId")));
            entity.addPart("returnformat", new StringBody("json"));
            entity.addPart("uploaded", new ByteArrayBody(data,"myImage.jpg"));



    entity.addPart("photoCaption", new StringBody(caption.getText().toString()));
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost,
   localContext);
4

2 回答 2

2

在您的应用程序中添加一个 libs 文件夹,然后添加“httpmime-4.1.3.jar”,之后您需要将此目录显示到您的项目属性中。

于 2012-05-28T11:50:17.157 回答
0

您应该将此 JAR 添加到构建路径。如果您使用的是 Eclipse,只需将其复制到项目文件夹即可。然后在 Eclipse 中右键单击它,BUILD PATH->ADD TO BUILD PATH

于 2012-05-22T15:45:55.810 回答