首先,需要有这两个三方类文件,如图1和如图3:
方法一:
点开如图一的CLNetWorkingManager.m
上传图片方法如下:
然后在viewController.m中,
//创建CLImageModel
NSData *image = [defaults objectForKey:@"imageData"];
CLImageModel *model = [[CLImageModel alloc]init];
model.image = [UIImage imageWithData:image];
model.field = @"mPhoto";
//整体参数拼接(sendCandidates+会员号+token+jsonString+mPhoto)
NSDictionary *submitDic = [NSDictionary dictionaryWithObjectsAndKeys:@"sendCandidates",@"reqCode",[defaults objectForKey:@"MemberId"],@"memberId",en,@"token",ecryptText,@"jsonString", nil];
NSLog(@"整体参数:%@",submitDic);
//网络请求
[CLNetworkingManager uploadWithURLString: url parameters:submitDic model:model progress:^(float writeKB, float totalKB) {
} succeed:^{
} fail:^(NSError *error) {
}];
方法二: