Send an Mp4 video to the PHP server via ASIFormDataRequest

advertisements

Here I am sending the file path or file with some parameters. But the server didn't get the video. So any problem in that code? Or anything you want to add something. Then please tell me. Any delegate method you want to tell me where I get error or setting in response .

NSString *path = [[NSBundle mainBundle] pathForResource:@"hangover" ofType:@"mp4"];

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://156.75.28.172:52/aircas/RestServices/fileUpload"]];

[request setPostValue:filename forKey:@"name"]; 

[request setPostValue:@"GUnit" forKey:@"title"];
[request setPostValue:@"133" forKey:@"user_id"];
[request setPostValue:@"8953d0e1c97ef83c9f0aff47" forKey:@"token"];
[request setPostValue:@"video song" forKey:@"desc"];
[request setPostValue:@"34" forKey:@"video_id"];
[request setPostValue:@"0" forKey:@"is_private"]; 

[request setFile:path forKey:@"video"];

[request setTimeOutSeconds:500];
[request setRequestMethod:@"POST"];

[request startSynchronous];


Try this...

NSString *path = [[NSBundle mainBundle] pathForResource:@"hangover" ofType:@"mp4"];
    NSURL *fileURL = [NSURL fileURLWithPath:path];
        NSData *movieData = [NSData dataWithContentsOfURL:fileURL];

    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://156.75.28.172:52/aircas/RestServices/fileUpload"]];

     [request setPostValue:filename forKey:@"name"]; 

    [request setPostValue:@"GUnit" forKey:@"title"];
     [request setPostValue:@"133" forKey:@"user_id"];
     [request setPostValue:@"8953d0e1c97ef83c9f0aff47" forKey:@"token"];
     [request setPostValue:@"video song" forKey:@"desc"];
    [request setPostValue:@"34" forKey:@"video_id"];
    [request setPostValue:@"0" forKey:@"is_private"]; 

    [self.request setData:movieData withFileName:@"hangover.mp4" andContentType:@"multipart/form-data" forKey:@"video"];

    [request setTimeOutSeconds:500];
    [request setRequestMethod:@"POST"];

    [request startSynchronous];

Hope it helps.