标签:
// 1.创建请求管理对象
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//2.发送请求
NSMutableDictionary * paramters = [NSMutableDictionary dictionary];
paramters[@"uid"] = [self getUserID];
PKLog(@"paramters==%@",paramters);
// 转换成NSData保存
NSArray *imageArr = [NSArray arrayWithObjects:self.bindingBtn.imageView.image, self.positiveBtn.imageView.image,self.BackBtn.imageView.image,nil];
NSString *urlStr = [NSString stringWithFormat:@"%@%@",PKServerIP,@"/api/v1/validate/getimg"];
[manager POST:urlStr parameters:paramters constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
PKLog(@"self.imageArray=%@",imageArr);
for (int i=0; i<imageArr.count; i++) {
UIImage * image =imageArr[i];
NSData *data = UIImageJPEGRepresentation(image, 1.0);
NSString *name =[NSString stringWithFormat:@"image%d.png",i];
NSString *formKey =[NSString stringWithFormat:@"image%d",i];
NSString *type = @"image/png";
[formData appendPartWithFileData:data name:formKey fileName:name mimeType:type];
}
PKLog(@"formData=%@",formData);
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
PKLog(@"responseObject = %@",responseObject);
[self HUDShowText:@"上传成功,我们将尽快为您审核" completBlock:^{
//返回
[self.navigationController popViewControllerAnimated:YES];
}];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
PKLog(@"error=%@",error);
[self HUDShowText:@"上传失败"];
}];
标签:
原文地址:http://www.cnblogs.com/somebodywx/p/5724607.html