0

I have upload a file through my server and its working fine, but i want to show a progressview for upload status, How to do this, Please help me

Thanks in Advance

I tried this:

        [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"file\"; filename=\"%@\"\r\n",file] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
        [body appendData:Filedata];
        [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
        [request setHTTPBody:body];


        NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
        if (theConnection)
            mutaebleData = [[NSMutableData data] retain];
        else
            NSLog(@"No Connection");

Using this delegate to Upload data status, but it wont help

- (void)request:(NSURLConnection *)request 
didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
    NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);
}
iPatel
  • 46,010
  • 16
  • 115
  • 137
SampathKumar
  • 2,525
  • 8
  • 47
  • 82

3 Answers3

1

Please have a look at this thread,It will help you:

How to track the progress of a download using ASIHTTPRequest (ASYNC)

Community
  • 1
  • 1
Banker Mittal
  • 1,918
  • 14
  • 26
0

This is the Best Custom controller for you.

It Custom UIActivityIndicator that you can found from this link

https://github.com/jdg/MBProgressHUD

These is not apple specific controls. This MBProgressHUD controls consist of Three controls that describe in below.

  • Background UIImageView with the image.
  • UIActivityIndicatory
  • UILabel with whatever message you want to display.

MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.......
For mor information go to above Link

iPatel
  • 46,010
  • 16
  • 115
  • 137
-1

The simplest you can alert a UIProgressView and int the delegate you can set the value of progress for example:

- (void)request:(NSURLConnection *)request 
didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
{
    NSLog(@"%d bytes out of %d sent.", totalBytesWritten, totalBytesExpectedToWrite);

    UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
    [self.view addSubview:progressView];
    progressView.progress = (double) bytesWritten / totalBytesWritten;
}
Siverchen
  • 379
  • 2
  • 16