title: iOS UIImagePickerController result image orientation after upload
body: <p>I am testing my iPhone application on an iOS 3.1.3 iPhone.  I am selecting/capturing an image using a <code>UIImagePickerController</code>:</p>
  
  <pre><code>UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
  [imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
  [imagePicker setDelegate:self];
  [self.navigationController presentModalViewController:imagePicker animated:YES];
  [imagePicker release];
  
  
  
  - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
      self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
      imageView.image = self.image;
      [self.navigationController dismissModalViewControllerAnimated:YES];
      submitButton.enabled = YES;
  }
  </code></pre>
  
  <p>I then at some point send it to my web server using the ASI classes:</p>
  
  <pre><code>ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://example.com/myscript.php"]];
  [request setDelegate:self];
  [request setStringEncoding:NSUTF8StringEncoding];
  [request setShouldContinueWhenAppEntersBackground:YES];
  //other post keys/values
  [request setFile:UIImageJPEGRepresentation(self.image, 100.0f) withFileName:[NSString stringWithFormat:@"%d.jpg", [[NSDate date] timeIntervalSinceNow]] andContentType:@"image/jpg" forKey:@"imageFile"];
  [request startAsynchronous];
  </code></pre>
  
  <p>the problem:
  when i take a picture with the iphone while holding it landscape, the image gets uploaded to the server and it viewed like you would expect.  when taking a picture holding the phone in portrait, the image is uploaded and viewed as it had been rotated 90 degrees.</p>
  
  <p>my application is set to only work in portrait modes(upsidedown and regular).</p>
  
  <p>How can i make the image always show the correct orientation after uploading?</p>
  
  <p>the image appears to be correct as displayed in an UIImageView(directly after taking the picture), but viewing on the server says otherwise.</p>