-
(void)upDateHeadIcon:(UIImage *)photo{
//两种方式上传头像 /方式一:使用NSData数据流传图片/
NSString *imageURl = @"";
manager.responseSerializer = [AFHTTPResponseSerializer serializer]; manager.responseSerializer.acceptableContentTypes =[NSSet setWithObject:@"text/html"]; [manager POST:imageURl parameters:nil constructingBodyWithBlock:^(idformData) {
[formData appendPartWithFileData:UIImageJPEGRepresentation(photo, 1.0) name:@"text" fileName:@"test.jpg" mimeType:@"image/jpg"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
/方式二:使用Base64字符串传图片/
NSData *data = UIImageJPEGRepresentation(photo, 1.0);
NSString *pictureDataString=[data base64Encoding];
NSDictionary * dic = @{@"verbId":@"modifyUserInfo",@"deviceType":@"ios",@"userId":@"",@"photo":pictureDataString,@"mobileTel":@""};
[manager POST:@"" parameters:dic success:^(AFHTTPRequestOperation *operation, id responseObject) {
if ([[responseObject objectForKey:@"flag"] intValue] == 0) {
}else{
}
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
}
网友评论