如何通过JSON以编程方式在iPhone应用程序中同时选择视频和图像?

时间:2011-10-19 05:06:06

标签: iphone

任何人都可以通过JSON以编程方式帮助我在iphone应用程序中同时选择视频和图像吗?

这是我的代码:

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]];