title: UIImage upload to jsp server
body: <p>I'm trying to upload a image file to server but it is not getting uploaded below i have added my code</p>
  
  <pre><code>imageData = UIImageJPEGRepresentation(imageToUpload, 0.9f);
  
  NSString *urlString =@"http://sample.com/LargeUpload.jsp";
  
  NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  [request setURL:[NSURL URLWithString:urlString]];
  [request setHTTPMethod:@"POST"];
  [request setTimeoutInterval:10];
  
  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:[@"Content-Disposition: form-data;filename=\"\"\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];
  
  NSData *returnData = [ NSURLConnection sendSynchronousRequest:request returningResponse:YES error: nil ];
  </code></pre>