Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3990658
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:31:18+00:00 2026-05-20T06:31:18+00:00

This is the code that i use for upload the video to web server

  • 0

This is the code that i use for upload the video to web server

-(void)startParsingForVedioUploade:(NSMutableDictionary*)vedioDict{

    NSURL *videoURL = [vedioDict valueForKey:@"VideoUrl"];

    NSData *myData = [[NSData alloc] initWithContentsOfURL:videoURL];

    NSString *urlString = [NSString stringWithFormat:@"http://www.Example.com/uploadvideoxml.php?user_id=%@",[vedioDict valueForKey:@"user_id"]];
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];
    NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
    [request addValue:contentType forHTTPHeaderField: @"Content-Type"];
    NSMutableData *body = [NSMutableData data];
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@\"\r\n",[myWords lastObject]]] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[NSData dataWithData:myData]];
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [request setHTTPBody:body];
    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:returnData];     
    [xmlParser setDelegate:self];
    [xmlParser parse];
}

-(void)uploadeVideoClicked{

    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];

    ipc.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;

    ipc.mediaTypes =[UIImagePickerController availableMediaTypesForSourceType:ipc.sourceType];     

    ipc.delegate = self;

    [self presentModalViewController:ipc animated:YES];

}



#pragma mark -----------------------------
#pragma mark Image Picker Delegate Methods

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

{

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if ([mediaType isEqualToString:@"public.image"]){

        UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"" message:@"You Select a image Please select Movie" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [myAlertView show];
        [myAlertView release];
    }

    else if ([mediaType isEqualToString:@"public.movie"]){

        NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

        NSLog(@"found a video");

        NSData *webData = [NSData dataWithContentsOfURL:videoURL];
        [info setValue:webData forKey:@"VideoUrl"];
        [info setValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:@"user_id"] forKey:@"user_id"];
        [[pParsing sharedInstance] assignSender:self];
        [[pParsing sharedInstance] startParsingForVedioUploade:info];
    }

    [picker dismissModalViewControllerAnimated:YES];

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:31:19+00:00Added an answer on May 20, 2026 at 6:31 am
    -(void)uploadeVideoClicked{
    
        if (_picker) {
            [_picker dismissModalViewControllerAnimated:NO];
            [_picker.view removeFromSuperview];
            [_picker release];
        }
        if (_popover) {
            [_popover dismissPopoverAnimated:NO];
            [_popover release];
        }
        _picker = [[[UIImagePickerController alloc] init] retain];
        _picker.delegate = self;
        _picker.editing = NO;
        _picker.allowsEditing=NO;
        _picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        _picker.wantsFullScreenLayout = YES;
    
        _picker.videoQuality =UIImagePickerControllerQualityTypeLow;
        _picker.mediaTypes =[NSArray arrayWithObject:(NSString *)kUTTypeMovie];
        _popover = [[[UIPopoverController alloc] initWithContentViewController:_picker] retain];
        [_popover setDelegate:self];
        [_popover presentPopoverFromRect:infoButton.frame
                                  inView:self.view
                permittedArrowDirections:UIPopoverArrowDirectionAny
                                animated:YES];
    }
    #pragma mark -----------------------------
    #pragma mark Image Picker Delegate Methods
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    { 
    
        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    
        if ([mediaType isEqualToString:@"public.image"]){
    
    
    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"" message:@"You Select a image Please select Movie" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    
            [myAlertView show];
    
            [myAlertView release];
    
        }
        else if ([mediaType isEqualToString:@"public.movie"]){
    
            NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
            //NSLog(@"found a video");
            if (webData) {
                [webData release];
                webData = nil;
            }
    
        webData = [[NSMutableData alloc]initWithContentsOfURL:videoURL];
    
           // webData = [NSData dataWithContentsOfURL:videoURL];
    
            spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    
            spinner.center = self.view.center;
    
            [self.view addSubview:spinner];
    
            [spinner startAnimating];
    
        [self performSelector:@selector(uploadVideo) withObject:nil afterDelay:.001];
    
        }
    
        [_picker dismissModalViewControllerAnimated:YES];
        [_picker.view removeFromSuperview];
        [_picker release];
        _picker = nil;
        [_popover dismissPopoverAnimated:YES];
        [_popover release];
    
    }
    -(void)uploadVideo
    {
    
    NSString *url = [NSString stringWithFormat:@"http://example.com/uploadvideoxml.php"];
    
        networkQueue = [[ASINetworkQueue alloc] init];
    
        [networkQueue cancelAllOperations];
    
        [networkQueue setShowAccurateProgress:YES];
    
        [videoUploadProgressView setHidden:NO];
    
        progressView.center = self.view.center;
    
        [self.view addSubview:progressView];
    
        [networkQueue setUploadProgressDelegate:videoUploadProgressView];
    
        [networkQueue setDelegate:self];
    
        [networkQueue setRequestDidFinishSelector:@selector(requestFinished:)];
    
        [networkQueue setRequestDidFailSelector: @selector(requestFailed:)];
    
    
        request= [[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:url]] ;
    
        [request setPostValue:[[mAppDelegate.userInfoArray objectAtIndex:1]valueForKey:@"user_id"] forKey:@"user_id"];
    
        [request addRequestHeader:@"Content-Type"
                            value:@"multipart/form-data;boundary=---------------------------1842378953296356978857151853"];
    
    
        NSDate *date1=[NSDate date];
    
        NSDateFormatter *formatter1 = [[NSDateFormatter alloc] init];
    
        [formatter1 setDateFormat:@"hh:mm"];
    
        NSString *valuestr = [formatter1 stringFromDate:date1];
    
        ////NSLog(@"%@",valuestr);
    
        [formatter1 release];
    
        NSString *moviename = [NSString stringWithFormat:@"WakeUUUP_%d_%@.mov",[videolistArray count],valuestr];
        if(webData != nil){
            [request setFile:webData withFileName:moviename andContentType:@"video/quicktime" forKey:@"userfile"];
        }
    
        [request setTimeOutSeconds:5000];
        //NSLog(@"%@",request);
        [networkQueue addOperation:request];
        [networkQueue go];
    }
    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
    {
        [_picker dismissModalViewControllerAnimated:YES];
        [_picker.view removeFromSuperview];
        [_picker release];
        _picker = nil;
        [_popover dismissPopoverAnimated:YES];
        [_popover release];
    }
    
    //for Ipad UIPopoverController if there is a cancel when the user click outside the popover
    - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
    {
        [_picker dismissModalViewControllerAnimated:YES];
        [_picker.view removeFromSuperview];
        [_picker release];
        _picker = nil;
    }
    
    #pragma mark -------------------------
    #pragma mark ASIHTTPREQUEST Delegate 
    - (void)requestFailed:(ASIHTTPRequest *)req
    {
    
        [progressView removeFromSuperview];
        [videoUploadProgressView setHidden:YES];
        ////NSLog(@"Request failed: %@",[req error]);
        UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Failed to Post Item" message:[[req error] description] delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil, nil];
        [errorAlert show];
        [errorAlert release];
        [networkQueue release];
        [request release];
    }
    - (void)requestFinished:(ASIHTTPRequest *)req
    {
        [networkQueue release];
        [request release];
        [progressView removeFromSuperview];
        [videoUploadProgressView setHidden:YES];
    
        [[Parsing sharedInstance] assignSender:self];
        NSMutableArray *resultArray =[[[NSMutableArray alloc]initWithArray:[[Parsing sharedInstance]startparsingforfun:[req responseData]]]autorelease];
    
        NSLog(@"Response was: %@",resultArray);
        if (spinner) {
            [spinner stopAnimating];
            [spinner removeFromSuperview];
            [spinner release];
            spinner = nil;
        }
        if ([[[resultArray objectAtIndex:1]objectForKey:@"Transaction"]isEqualToString:@"uploadvideoxml"]) {
            if ([[[resultArray objectAtIndex:1]objectForKey:@"success"]isEqualToString:@"true"]) {
                [self viewWillAppear:YES];
    
            }else {
    
                UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Failed to Update  Profile" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil, nil];
                [errorAlert show];
                [errorAlert release];
            }
    
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code that I want to write is like this: void MethodOnThreadA() { for
I have this code that performs an ajax call and loads the results into
So I have this code that takes care of command acknowledgment from remote computers,
I'm a newbie to python and the app engine. I have this code that
I have this jQuery code that queries an API on a keyup event (via
I have this legacy code that I am working with and there is code
Is there an easy way to modify this code so that the target URL
I have this small code library that I'm considering releasing into Open Source. I
Well, I have this bit of code that is slowing down the program hugely
I've got a problem with inheritance and generics. This is the code that illustrates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.