首页 > 代码库 > 把一张图片 转成二进制流 用AFNetworking POST 上传到服务器.
把一张图片 转成二进制流 用AFNetworking POST 上传到服务器.
把一张图片 转成二进制流 用AFNetworking POST 上传到服务器.
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:BaseUrl]];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer.timeoutInterval = TimeoutInterval;
[manager POST:Request_updateCompanyInfo parameters:paramDict constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSData *data=http://www.mamicode.com/UIImagePNGRepresentation(_userImage);
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
// 设置时间格式
formatter.dateFormat = @"yyyyMMddHHmmss";
NSString *str = [formatter stringFromDate:[NSDate date]];
NSString *fileName = [NSString stringWithFormat:@"%@.png", str];
[formData appendPartWithFileData:data name:@"logo_img" fileName:fileName mimeType:@"image/png"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
[super stopLoadingCompletedWithMessage:@"提交成功"];
[self.navigationController popViewControllerAnimated:YES];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
把一张图片 转成二进制流 用AFNetworking POST 上传到服务器.