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 8898993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:44:57+00:00 2026-06-15T00:44:57+00:00

I know how to upload images to a server running PHP, but I am

  • 0

I know how to upload images to a server running PHP, but I am stuck on uploading video.

I have used this advice to upload my video file.

Posting method is all ok. What I get on the server is a file of 0 bytes.

My code is below:

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

    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    NSData *videoData = [NSData dataWithContentsOfFile:[videoURL path]];
}

This videoData is passed in my POST method.

What should I do instead?

  • 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-06-15T00:44:58+00:00Added an answer on June 15, 2026 at 12:44 am

    for posting video you need to use this function after image picker delegate

    - (NSData *)generatePostDataForData:(NSData *)uploadData
    {
        // Generate the post header:
        NSString *post = [NSString stringWithCString:"--AaB03x\r\nContent-Disposition: form-data; name=\"upload[file]\"; filename=\"somefile\"\r\nContent-Type: application/octet-stream\r\nContent-Transfer-Encoding: binary\r\n\r\n" encoding:NSASCIIStringEncoding];
    
        // Get the post header int ASCII format:
        NSData *postHeaderData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    
        // Generate the mutable data variable:
        NSMutableData *postData = [[NSMutableData alloc] initWithLength:[postHeaderData length] ];
        [postData setData:postHeaderData];
    
        // Add the image:
        [postData appendData: uploadData];
    
        // Add the closing boundry:
        [postData appendData: [@"\r\n--AaB03x--" dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
    
        // Return the post data:
        return postData;
    }
    
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ 
    
        //assign the mediatype to a string 
        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    
        //check the media type string so we can determine if its a video
        if ([mediaType isEqualToString:@"public.movie"]){
            NSLog(@"got a movie");
            NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
            NSData *webData = [NSData dataWithContentsOfURL:videoURL];
            [self post:webData];
            [webData release];
    
        }
    

    for post video use this function

    - (void)post:(NSData *)fileData
    {
    
        NSLog(@"POSTING");
    
        // Generate the postdata:
        NSData *postData = [self generatePostDataForData: fileData];
        NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
        // Setup the request:
        NSMutableURLRequest *uploadRequest = [[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.example.com:3000/"] cachePolicy: NSURLRequestReloadIgnoringLocalCacheData timeoutInterval: 30 ] autorelease];
        [uploadRequest setHTTPMethod:@"POST"];
        [uploadRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
        [uploadRequest setValue:@"multipart/form-data; boundary=AaB03x" forHTTPHeaderField:@"Content-Type"];
        [uploadRequest setHTTPBody:postData];
    
        // Execute the reqest:
        NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:uploadRequest delegate:self];
        if (conn)
        {
            // Connection succeeded (even if a 404 or other non-200 range was returned).
            NSLog(@"sucess");
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Got Server Response" message:@"Success" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
        else
        {
            // Connection failed (cannot reach server).
            NSLog(@"fail");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried this code to upload two images to PHP server. But response is
I have develop one web site in php. I know how to upload it
I use the PHP language for file upload and want to know that the
If I need a php-page to have access to upload images and move images
I have developed a small web app. This app allows users to upload images.
I'm trying to use uploadify to upload images to a remote server. I've have
I know this questions probably been used and abused.... but i keep seeing conflicting
I try to POST images to server. I have finished it successfully like this:
Got a question. I have images hosted on my server. I already know of
I just wanted to know how to configure FCKEditor to upload files and images

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.