我希望能够将ImageView的内容发送到在线服务器。我成功测试的代码如下。此代码将图像作为“命名”图像并将其作为多部分图像发送。我正在努力找到一种方法将ImageView的内容作为多部分图像发送。我需要帮助来找到ImageView的路径,或者指导这是否是错误的方法。这就是我的尝试:
HttpEntity resEntity;
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
File file1 = new File(selectedImage.getPath());
FileBody bin = new FileBody(file1);
entity.addPart("userID", new StringBody(id));
entity.addPart("uploadFile", bin);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
resEntity = response.getEntity();
final String response_str = EntityUtils.toString(resEntity);
System.out.println(response_str);
提前致谢
答案 0 :(得分:0)
我能够使用Get file path of image on Android上接受的答案找到我的ImageView的路径以寻求帮助。全部归功于@Siddharth Lele。