使用第三方请求工具类上传图片
我这里的例子是服务器接受方式为multipart/form-data
例:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
AFHTTPRequestSerializer *serializer = [[AFHTTPRequestSerializer alloc]init];
manager.requestSerializer = serializer;
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager POST:path parameters:param constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:imageData name:@"hello.png" fileName:@"hello.png" mimeType:@"multipart/form-data"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];