How to convert UIImage
or NSDate
to byte array and post to server.
In my app i have to convert UIImage
to byte array and i have to post.
for post i am using as ASIFormDataRequest
.
My code is:
NSUInteger len = [self.dataImage length];
Byte *byteData= (Byte*)malloc(len); //converting date to byte array
[self.dataImage getBytes:byteData length:len];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:urlStr]];
[request setRequestMethod:@"POST"];
[request addData:self.dataImage withFileName:@"Image.png" andContentType:@"image/png" forKey:@"photo"];
[request setDelegate:self];
[request startAsynchronous];