1

Can any body help me how to select video and image both at the same time in iphone app programmatically through JSON?

Here is my code:

urlString = [NSString stringWithFormat:@"%@",@"http://millioninone.cisusa.net/rest/index.php?c=save&m=savevideo"];
NSLog(@"%@",urlString);
//urlString=[urlString stringByAppendingFormat:@"product.php?strJSON="];
NSString *filename = @"postVideo";
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:urlString]];

[request setHTTPMethod:@"POST"];

NSMutableData *body = [NSMutableData data];

NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];

NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];

[request addValue:contentType forHTTPHeaderField:@"Content-Type"];

// if(imagedatabool)//ye image data ka object h jisme image jati h agar tujhe image nahi bjhna h to ye rehne dena

// {
NSString *str=@"/Users/CIS1/Library/Application Support/iPhone Simulator/4.3/Media/DCIM/100APPLE/IMG_0042.MP4";
videoData=[NSData dataWithContentsOfFile:str];
// add the image form fields
// NSData *imageData = UIImagePNGRepresentation(imgView.image);
//NSLog(@"%@",imageData);


[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
Cœur
  • 37,241
  • 25
  • 195
  • 267
Shilpa
  • 340
  • 1
  • 4
  • 14

1 Answers1

0

You're just forming the request object. You need to init the request against the NSUrlConnection object and implement the callback methods:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSURLConnectionDelegate

Here's a related SO post that was posting data:

Posting to yFrog objc

Community
  • 1
  • 1
bryanmac
  • 38,941
  • 11
  • 91
  • 99