-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
NSLog(@"选择了图片:%@",[info objectForKey:UIImagePickerControllerEditedImage]);
NSLog(@"dictionary:%@",info);
[self.picShow setImage:[info objectForKey:UIImagePickerControllerEditedImage] forState:UIControlStateNormal];
NSString *path=@"http://www.12311148.com";
AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
[manager POST:path parameters:@{@"user":@"15"} constructingBodyWithBlock:^(id formData){
UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
NSData *data=UIImagePNGRepresentation(image);
[formData appendPartWithFileData:data name:@"file" fileName:@"1.png" mimeType:@"image.jpg"];
}success:^(AFHTTPRequestOperation *operation,id responseObject){
NSString *str=[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding];
NSLog(@"%@",str);
}failure:^(AFHTTPRequestOperation *operation,NSError *error){
NSLog(@"%@",error.description);
}];
[picker dismissViewControllerAnimated:YES completion:nil];
}
IOS上传图片到服务器
最新推荐文章于 2020-12-28 22:56:46 发布