您需要创建一个http post请求并添加图像作为请求的主体。
与此类似
NSString *boundary = @"AaB03x";
NSMutableData *postbody = [NSMutableData data];
[postbody appendData:[[NSString stringWithFormat:@"--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"imageFile.png\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n",IMAGE_MIME_TYPE] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[NSData dataWithContentsOfFile:@"pass the file path here"]];
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
//////////////////////////////PREPARING POST REQUEST BODY/////////////////////////////////////////////
NSMutableURLRequest *uploadRequest = [[NSMutableURLRequest alloc]
initWithURL:[NSURL URLWithString:@"url to server"]
cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:45];
[uploadRequest setHTTPMethod:@"POST"];
[uploadRequest setValue:@"multipart/form-data; boundary=AaB03x" forHTTPHeaderField:@"Content-Type"];
[uploadRequest setHTTPBody:postbody];