1 //创建httpUtils对象 2 HttpUtils mRegHttpUtils = new HttpUtils(); 3 //图片路径 4 String path = "/sdcard/Download/zxing.jpg"; 5 //param 6 RequestParams params = new RequestParams(); 7 //将图片封装为file 8 params.addBodyParameter("f_img",new File(path)); 9 //以post方式发送到urlstring服务器 10 mRegHttpUtils.send(HttpMethod.POST, 11 urlstring, params, 12 new RequestCallBack<String>() { 13 14 @Override 15 public void onFailure(HttpException arg0, 16 String arg1) { 17 // TODO Auto-generated method stub 18 Log.i("tag", "failed" + arg0.toString()); 19 } 20 21 @Override 22 public void onStart() { 23 // TODO Auto-generated method stub 24 super.onStart(); 25 } 26 27 @Override 28 public void onSuccess(ResponseInfo<String> arg0) { 29 // TODO Auto-generated method stub 30 //返回结果
Log.i("tag","success"+arg0.result); 31 32 33 } 34 });