title: Which is the better (faster) way to upload image on server
body: <p>I have learned two method(Probably there is more..) to upload image on server..</p>
  
  <p><strong>1) Create NSData and add it into request body<br>
  2) Create Byte Array and send it in json like simple array</strong></p>
  
  <p><strong><em>1) Create NSData and add it into request body</em></strong></p>
  
  <p>Create NSData from the image using this code</p>
  
  <pre><code>NSData *imageData = UIImagePNGRepresentation(myimage);
  </code></pre>
  
  <p>And than add it in request body</p>
  
  <pre><code>NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
  [request setURL:[NSURL URLWithString:urlString]];
  [request setHTTPMethod:@"POST"];
  [body appendData:[NSData dataWithData:imageData]];
  [request setHTTPBody:body];
  </code></pre>
  
  <p>Perform request and Image will be uploaded on server.</p>
  
  <p><strong><em>2) Create Byte Array and send it in json like simple array</em></strong></p>
  
  <p>Create Byte array of image</p>
  
  <pre><code>NSData *imageData = UIImagePNGRepresentation(myimage);
  
  const unsigned char *bytes = [imageData bytes];
  NSUInteger length = [imageData length];
  NSMutableArray *byteArray = [NSMutableArray array];
  for (NSUInteger i = 0; i&lt;length; i++)
  {
     [byteArray addObject:[NSNumber numberWithUnsignedChar:bytes[i]]];
  }
  </code></pre>
  
  <p>And than send it in request using JSON like any other array</p>
  
  <p><strong><em>But which is the better solution or there is another faster way..</em></strong></p>