title: iPhone - How to show progress bar when uploading an image to the server?
body: <p>I want to display a progress bar, when user will upload any image to the server. my image is uploading successfully to the server using php url. But for this i am not using any NSUrlConnection class. Actually i am uploading multiple of images from different different  view controller classes, so i have added a method in my Util class for common uploading image, where i am passing image data &amp; image ID. So how can i implement NSUrlConnection delegates in my below case :</p>
  
  <p>Here is my Util Class Method :</p>
  
  <pre><code>+(void)uploadImageOnServer:(NSData *)imageData forId:(NSString *)imageId
  {
       NSString *urlString = @"http://url...............";
  
      // setting up the request object now
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
  
      [request setURL:[NSURL URLWithString:urlString]];
  
      [request setHTTPMethod:@"POST"];
  
      NSString *boundary = @"---------------------------147378098314876653456641449";
  
      NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
  
      [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
  
      /*
       now lets create the body of the post
       */
      NSMutableData *body = [NSMutableData data];
  
      [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
  
      NSString *stringData = [NSString stringWithFormat:@"Content-Disposition: form-data; name=\"Documents\"; filename=\%@.jpg\r\n",imageId];
  
      [body appendData: [stringData 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];
  
      // now lets make the connection to the web
      NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
  
      NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
  }
  </code></pre>
  
  <p>From My ViewController class, i am calling above method for uploading an image to server as:</p>
  
  <pre><code>[Util uploadImageOnServer:positionData forId:positionImageId];
  </code></pre>
  
  <p>It is taking around 4-5 seconds for uploading one image to the server. I want to add progress view like this attached screenshot. Can you pls guide me how can i integrate common NSUrlConnection delegates in my Util Class for displaying to the user that how much data has been uploaded ?</p>
  
  <p>Thanks.</p>
  
  <p><img src="https://i.stack.imgur.com/xuaWD.png" alt="enter image description here"></p>