AFNetworking 2.3.1 上传图片 服务器无法接收到图片?
我使用的最新版本的AFNetworking 2.3.1 该版本已经没有AFHttpClient这个类了 于是使用wiki中的这种方式上传图片
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
NSDictionary *parameters = @{@"foo": @"bar"};
UIImage *image = [UIImage imageNamed:@"xxxx"];
[manager POST:@"http://example.com/resources.json" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:UIImagePNGRepresentation(image)
name:@"avatar"
fileName:@"avatar.png"
mimeType:@"image/png"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
但是服务器一直接受不到图片数据。这里的name与filename参数有什么要求吗?
up主是大好人
10 years, 4 months ago