title: How to upload image to remote server in iphone?
body: <p>I am trying to upload a image which i am clicking with the help of the camera. I am trying the following code to upload the image to the remote server.</p>
  
  <pre><code>-(void)searchAction:(UIImage*)theImage
  {
      UIDevice *dev = [UIDevice currentDevice];
      NSString *uniqueId = dev.uniqueIdentifier;
  
      NSData * imageData = UIImagePNGRepresentation(theImage);
  
      NSString *postLength = [NSString stringWithFormat:@"%d",[imageData length]];
  
      NSString *urlString = [@"http://www.amolconsultants.com/im.jsp?" stringByAppendingString:@"imagedata=iPhoneV0&amp;mcid="];
      urlString = [urlString stringByAppendingString:uniqueId];
      urlString = [urlString stringByAppendingString:@"&amp;lang=en_US.UTF-8"];
  
      NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
      [request setURL:[NSURL URLWithString:urlString]];
      [request setHTTPMethod:@"POST"];
      [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
      [request setHTTPBody:imageData];
  
      NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self];
      if (conn == nil) 
      {
          NSLog(@"Failed to create the connection");
      }
  }
  </code></pre>
  
  <p>But nothing is getting posted. Nothing comes in the console window also. I am calling this method in the action sheet. When the user clicks on the 1st button of the action sheet this method is called to post the image.</p>
  
  <p>Can anyone help me with this...</p>
  
  <p>Any code will be very helpful...</p>
  
  <p>Thanx in advance...</p>