如何将视频文件上传到网络服务器iphone sdk

时间:2012-05-10 10:11:45

标签: objective-c

我正在尝试使用UIImagePickerController将视频上传到网络服务器。请建议我如何做或提供样品。

1 个答案:

答案 0 :(得分:0)

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

NSURL *urlvideo = [info objectForKey:UIImagePickerControllerMediaURL];


//urlvideo contains the URL of that video file that has to be uploaded. Then convert the url into NSString type because setFile method requires NSString as a parameter

NSString *urlString=[urlvideo path];

NSLog(@"urlString=%@",urlString);
NSString *str = [NSString stringWithFormat:@"path of server"];

NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

[request setFile:urlString forKey:@"key foruploadingFile"];

[request setRequestMethod:@"POST"];

[request setDelegate:self];

[request startSynchronous];

NSLog(@"responseStatusCode %i",[request responseStatusCode]);

NSLog(@"responseStatusCode %@",[request responseString]);

}