引入afnetworking
AFHTTPRequestOperationManager初始化manager
AFHTTPRequestOperationManager *mag = [AFHTTPRequestOperationManager manager];
mag.responseSerializer = [AFHTTPResponseSerializer serializer];
NSString *url = [NSString stringWithFormat:@”%@updateImg”,K_URL];
[mag POST:url parameters:@{imageName:imageurl} constructingBodyWithBlock:^(id formData) {
[formData appendPartWithFileData:data name:@”image” fileName:@”image.png” mimeType:@”image/png”];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@”成功%@”,responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@”失败%@”,error);
}];