Thursday, 15 August 2013

iphone - Send the image on API using post method from imagepicker -



iphone - Send the image on API using post method from imagepicker -

i want create registration form, here have taken uitextfield info in string , send on api using post method don't know how send image on api data?

try next code snippet

afhttprequestoperationmanager *manager = [[afhttprequestoperationmanager alloc] initwithbaseurl: [nsurl urlwithstring:@"your url"]]; nsdictionary *parameters = [nsdictionary dictionarywithobjectsandkeys:@"yourvalue",@"valuename",@"yourvalue",@"valuename", nil]; nsdata *imagedata = uiimagepngrepresentation(img_picture); [manager post:@"your url" parameters:parameters constructingbodywithblock:^(id<afmultipartformdata> formdata) { [formdata appendpartwithfiledata:imagedata name:@"logo" filename:@"image.png" mimetype:@"image/png"]; } success:^(afhttprequestoperation *operation, id responseobject) { nslog(@"success %@", responseobject); } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"failure %@, %@", error, operation.responsestring); }];

where parameters contains textfield's data.

and logo image parameter name used in api coding.

iphone

No comments:

Post a Comment