This is easy to do with the AFNetworking library, and you can also use it to track the progress of video downloads. You can download the AFNetworking library from here .
And to configure AFnetworking, refer to Link .
And this code will be used to send video to the server
NSString *videoURL = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mov"]; NSData *videoData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath: videoURL]]; AFHTTPClient *httpClient = [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:@"http://www.example.com"]]; NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/videoupload.php" parameters:nil constructingBodyWithBlock:^(id <AFMultipartFormData>formData) { [formData appendPartWithFileData:videoData name:@"file" fileName:@"myVideo.mov" mimeType:@"video/quicktime"]; }]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest: request]; [operation setUploadProgressBlock:^(NSInteger bytesWritten,long long totalBytesWritten,long long totalBytesExpectedToWrite) { NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite); }]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {NSLog(@"Video Uploaded Successfully");} failure:^(AFHTTPRequestOperation *operation, NSError *error) {NSLog(@"Error : %@", operation.responseString);}]; [operation start];
source share