任何人都可以通过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]];
答案 0 :(得分:0)
您只是形成了请求对象。您需要针对NSUrlConnection对象初始化请求并实现回调方法:
以下是发布数据的相关SO帖子: