基于AFN的多张图片上传
不废话,直接上代码
NSString *urlString = [NSString stringWithFormat:@"http://192.168.1.166:8080/DisciplineServer/mobile/MobileClientAddReportInfo"]; AFHTTPSessionManager *manage = [AFHTTPSessionManager manager]; //参数 NSString *isRealStr = _isRealName?@"1":@"0"; NSDictionary *dic = @{ @"REPTYPE":self.model.ID, @"REALIZE":isRealStr, @"CITYADDRESS":_cityStr, @"AREAADDRESS":_areaStr, @"REPTITLE":_titleText.text, @"REPCONTENT":_textView.text, @"REPNAME":_nameText.text, @"REPPHONE":_phoneText.text }; //图片参数 for (NSInteger index = 0; index < _imgArr.count; index ++) { NSString *result = [_imgArr[index] base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed]; NSString *keyStr = [NSString stringWithFormat:@"IMG%ld",index+1]; [_imgDic setObject:result forKey:keyStr]; } [_imgDic addEntriesFromDictionary:dic]; NSMutableDictionary *params = [Tool requestParamsWithDictionary:_imgDic]; [manage POST:urlString parameters:params progress:^(NSProgress * _Nonnull uploadProgress) { } success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { // NSLog(@"%@",responseObject); NSString *contentStr = responseObject[@"detail"]; [Tool alertShow:[NSString stringWithFormat:@"举报成功,举报进度查询码:%@",contentStr]]; } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSLog(@"%@",error); }];