我想将图像、视频和音频文件上传到服务器。我已经阅读了关于类似主题的这个帖子,但无法完全理解代码的流程。如果您能建议我一些示例代码或教程开始,那就太好了。我正在使用以下代码在没有任何媒体的情况下连接到服务器
[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];
如果可以编辑这部分代码对我来说真的很方便。
任何形式的帮助将不胜感激。
提前致谢!!