老师,您好!请问在更改图像时使用xUtils上传文件到PHP服务器,服务器收不到参数和文件是怎么回事?
final RequestParams requestParams = new RequestParams();
requestParams.addBodyParameter("file", file);
requestParams.addQueryStringParameter("hkey", "HktS0lubMVgaQxB");
requestParams.addQueryStringParameter("mod", "user");
requestParams.addQueryStringParameter("act", "thumb");
requestParams.addQueryStringParameter("userid", mUser.getId() + "");
requestParams.addQueryStringParameter("locFilePath", mUser.getThumb());
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpRequest.HttpMethod.POST, Constant.commonUrl, requestParams, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Log.i("responseInfo---", responseInfo.result);
if (responseInfo.statusCode == 200) {
ToastMaker.showShortToast("上传成功");
}
dismiss();
}
@Override
public void onFailure(HttpException e, String s) {
e.printStackTrace();
}
@Override
public void onStart() {
Log.i("start===", "开始上传图片");
}
@Override
public void onLoading(long total, long current, boolean isUploading) {
if (isUploading) {
Log.i("upload: ", current + "/" + total);
} else {
Log.i("reply: ", current + "/" + total);
}
}
});