【发布时间】:2012-05-24 16:52:42
【问题描述】:
我想知道我们如何在 iPhone 中使用带有后台线程或进程的 web 服务上传大量图像。我在我的 iPhone 应用程序中存储大量图像,我想使用 .net 网络服务上传(发布)这些图像。现在,我正在使用 Web 服务发布单个图像,但我想在后台进程中发布多个图像。请帮助我,我将不胜感激。
【问题讨论】:
标签: iphone image web-services upload
我想知道我们如何在 iPhone 中使用带有后台线程或进程的 web 服务上传大量图像。我在我的 iPhone 应用程序中存储大量图像,我想使用 .net 网络服务上传(发布)这些图像。现在,我正在使用 Web 服务发布单个图像,但我想在后台进程中发布多个图像。请帮助我,我将不胜感激。
【问题讨论】:
标签: iphone image web-services upload
我认为您需要使用 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 As Asynchronous
【讨论】: