RequestParams params = new RequestParams();try { for (int i = 0; i < images.length; i++) { params.put("images["+i+"]", images[i], "image/jpeg"); } } catch (Exception e) { } AsyncHttpClient client = new AsyncHttpClient(); client.post(API.UPLOAD_IMAGE, params, new AsyncHttpResponseHandler() { @Override public void onFailure(int stateCode, Header[] header, byte[] data, Throwable error) { uploadImageListener.callback(null); } @Override public void onSuccess(int stateCode, Header[] header, byte[] data) { if (stateCode == 200) { JSONObject retObj = API.stringToJSONObject(new String(data)); uploadImageListener.callback(retObj); } } });
用 Async-Http 上传文件时 不支持多个文件同时传入 即不能放入File[]类型 需要循环放入
懂得太少 说不明白 藉此谨记
时间: 2024-10-15 03:29:35