我想将图像,视频和音频文件上传到服务器。我已阅读this thread的类似主题,但无法完全理解代码的流程。如果你能向我推荐一些示例代码或教程,那就太好了。我使用下面的代码,而无需任何介质连接到服务器通过xcode的多部分HTTP请求
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString *url =[[NSString alloc]initWithFormat:@"%@",[NetworkConstants getURL]];
NSURL *theURL =[NSURL URLWithString:url];
[url release];
NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:0.0f];
[theRequest setHTTPMethod:@"POST"];
NSString *theBodyString = [NSString stringWithFormat:@"json1=%@&userID=%@",jsonObject,[GlobalConstants getUID]];
NSData *theBodyData = [theBodyString dataUsingEncoding:NSUTF8StringEncoding];
[theRequest setHTTPBody:theBodyData];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (conn) {
NSLog(@"Successful in sending sync");
}
else {
NSLog(@"Failed Connection in sending sync");
}
[conn release];
这将是对我来说真的很方便,如果事情可以做编辑的这部分代码。
任何形式的帮助将不胜感激。
在此先感谢!
如果您正确标记了您的问题,您将会得到更好(或更多)的答案。仅仅因为你使用xcode编写代码并不意味着它与xcode相关。 –
感谢您的意见....将保持一个说明...... :) – devsri