2012-05-17 21 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