2.获衫樱取上瞎模传文件路径并判断是否为空
3.若不为空,创磨塌缓建异步请求对象
4.创建上传文件路径
5.执行post请求(指定url路径,封装上传参数,新建AsyncHttpResponseHandler方法)
直接实例化多个file传到params里面配搜就可以了RequestParams params = new RequestParams()
for (int i = 0i <list.size()i++) {
try {
params.put("培歼历images["改丛 + i + "]", new File(list.get(i)))
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
}
AreaHttpUtil.post(URL, params, new JsonHttpResponseHandler() {@Override
public void onSuccess(int statusCode, JSONObject response) {
super.onSuccess(statusCode, response)
Toast.makeText(AreaApplication.context, "上传成功", Toast.LENGTH_SHORT).show()
}
@Override
public void onFailure(int statusCode, Header[] headers,
String responseBody, Throwable e) {
super.onFailure(statusCode, headers, responseBody, e)
Toast.makeText(AreaApplication.context, "上传失败", Toast.LENGTH_SHORT).show()
}
public void onProgress(int current, int count) {
System.out.println("帆败袭current " + current)
System.out.println("total " + count)
upload.setProgress((int) (current / (float) count * 100))
upload.setText(current / 1024 + "枯渣/"态兄 + count / 1024 + "K")
Message message = new Message()
message.obj = upload
message.what = 1
GlobalHandler.getHandler().sendMessage(message)
}
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)