我想将图像从图库上传到我在android studio中的服务器,我编写了代码来上传图像,但是无法正常工作。
这是我的代码,用于将图像上传到服务器。
在android studio中。
public static String uploadImage(String filePath) throws IOException {
String url = "http://www.cbs-kw.com/3733";
String fileName = filePath;
//file to be uploaded
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
StringBody comment = new StringBody("Filename: " + fileName);
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("files", comment);
httppost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
return response.toString();
}
和textview.set()不起作用,找不到上载图片的结果吗?
代码中的问题所在!