- (void)upDateHeadIcon:(UIImage *)photo{??
? //兩種方式上傳頭像? ? /*方式一:使用NSData數(shù)據(jù)流傳圖片*/? ?
?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) {
}];
}