The following code should help
NSData *imageData = UIImagePNGRepresentation(image);
NSURL *yourURL = ...
NSMutableURLRequest *yourRequest = [NSMutableURLRequest requestWithURL:yourURL
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
[yourRequest setHTTPMethod:@"POST"];
[yourRequest setValue:@"image/png" forHTTPHeaderField:@"Content-Type"];
...
[yourRequest setHTTPBody:imageData];
NSURLConnection *yourConnection = [[NSURLConnection alloc] initWithRequest:yourRequest
delegate:self
startImmediately:YES];
Please note that you are using ARC.
source
share