1
votes

I am trying to uplaod video file to the specified url. when i press button video file should upload into the url which i used. but no respnse is comming. can any one pls give reason for this.

enter code here


    NSString *filePath = [[NSBundle mainBundle]pathForResource:@"3idiots" ofType:@"mov"];
    NSURL *uploadurl=[NSURL URLWithString:@"http://115.111.27.206:8081/vblo/upload.jsp"];

 //NSData *postVideoData = [NSData dataWithContentsOfFile:filePath];
NSData *postVideoData = [string dataUsingEncoding:NSASCIIStringEncoding         allowLossyConversion:YES];
NSString *postVideoLength = [NSString stringWithFormat:@"%d", [postVideoData length]];

NSMutableURLRequest *request12 = [[[NSMutableURLRequest alloc] init] autorelease]; 
[request12 setURL:uploadurl]; 
[request12 setHTTPMethod:@"POST"]; 
[request12 setValue:postVideoLength forHTTPHeaderField:@"Content-Length"]; 
[request12 setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
[request12 setHTTPBody:postVideoData];

NSURLConnection *theConnection12 = [[NSURLConnection alloc] initWithRequest:request12 delegate:self];

if( theConnection12 ) { webData12 = [[NSMutableData data] retain];

} else {

}

}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {

[webData12 setLength:0];

} -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {

[webData12 appendData:data];

} -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *loginStatus12 = [[NSString alloc] initWithBytes: [webData12 mutableBytes] length:[webData12 length] encoding:NSUTF8StringEncoding]; NSLog(loginStatus12);

 if(loginStatus12)
 {
  UIAlertView *statusAlert12 = [[UIAlertView alloc]initWithTitle:nil message:(NSString *)loginStatus12 delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:nil];
  [statusAlert12 show];
 }
}
1
you really need to clean up this code, it is hard to read... also what is in the variable "string" looks like you have commented out the actual video data - Aaron Saunders

1 Answers

0
votes

you need to send the request, add this line after you set the HTTPBody

NSData *serverReply = [NSURLConnection sendSynchronousRequest: request12 returningResponse:&response error:&error];