2012-05-17 20 views
3

我想知道如何在後臺線程或進程中使用iPhone中的webservice上傳許多圖像。我正在將大量圖像存儲在我的i​​Phone應用程序中,並且我想使用.net網絡服務上傳(張貼)這些圖像。現在,我正在使用網絡服務定位單個圖像,但我想在後臺進程中發佈多個圖像。請幫助我,我會爲此感激。在後臺線程中上傳大容量圖像

回答

2

我想你需要使用ASIHTTP請求,它使用異步調用服務器和多個圖像存儲在服務器上。

對於該方法用於上傳圖像後該方法的實現。

- (IBAction)btnPostImages_Clicked:(id)sender { 

    if ([arrImages count] > 0) { 
       NSString *strURL = @"Write Your URL Here."; 
       ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]]; 
       [request setDelegate:self]; 
       [request setPostValue:@"This is sample text..." forKey:@"text"]; 
       for (int i = 0; i < [arrImages count]; i++) { 
         [request addData:[arrImages objectAtIndex:i] withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:[NSString stringWithFormat:@"image%d", i + 1]]; 
       } 
[request startAsynchronous]; 
    } 
    else { 
       UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"Message" message:@"Please select images..." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
      [alertView show]; 
      [alertView release]; 
    } 
} 

你也可以按照本教程爲實施ASIHttp的異步

Reference Url Here