text: Q:
  
  Sending NSData and NSString in the same POST
  
  I am trying to follow this Insert imagedata into MySQL database from XCode using PHP & JSON answer to send a photo from my app to a MySQL database but I am confused as to how to add an NSString ID to reference to the POST body.
  We have the following to create the body which gets the image data:
          NSMutableData *body = [NSMutableData data];
  
          [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
          [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
          [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"image\"; filename=\"imagename.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
          [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
          [body appendData:[NSData dataWithData:imageData]];
          [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
  
          // setting the body of the post to the reqeust
          [request setHTTPBody:body];
  
  How might I send additional information such as a text ID within the same post? 
  
  A:
  
  Here is the whole code to post data along with Imagedata and string.
  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
      [request setHTTPMethod:@"POST"];
  
      NSString *boundary = @"---------------------------14737809831466499882746641449";
      NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
      [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
  
      NSMutableData *body = [NSMutableData data];
      [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
      [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"image\"; filename=\"imagename.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
      [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
      [body appendData:[NSData dataWithData:imageData]];
      [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
      [request setHTTPBody:body];
  
      NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
      [dict setObject:@"<YOUR TEXT>" forKey:@"<KEY>"];
  
      [body appendData:[self createFormData:dict withBoundary:boundary]];
      [request setHTTPBody:body];
  
      NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
      NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
      NSLog(@"%@", returnString);
  
  - (NSData*)createFormData:(NSDictionary*)myDictionary withBoundary:(NSString*)myBounds
  {
      NSMutableData *myReturn = [[NSMutableData alloc] init];
      NSArray *formKeys = [myDictionary allKeys];
      for (int i = 0; i < [formKeys count]; i++) {
          [myReturn appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",myBounds] dataUsingEncoding:NSASCIIStringEncoding]];
          [myReturn appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n%@",[formKeys objectAtIndex:i],[myDictionary valueForKey:[formKeys objectAtIndex:i]]] dataUsingEncoding:NSASCIIStringEncoding]];
      }
      return myReturn;
  }
  
  