0
我使用ASIHTTPRequest使用PHP上传照片。 PHP方面已经证明可以工作(我正在使用它的android),我试图让iOS组件工作。使用ASIHTTPRequest上传照片
这是我上传:
NSString *myurl = @"http://mydomain.tld/php/upload.php?casenum=";
myurl = [myurl stringByAppendingFormat: casenumber];
NSString *fixedURL = [myurl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSString stringWithFormat:@"%@",fixedURL];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSData *imageData = UIImageJPEGRepresentation(image1.image, 90);
[request setData:imageData withFileName:@"myphoto.jpg" andContentType:@"image/jpeg" forKey:@"file"];
[request setCompletionBlock:^{
NSString *responseString = [request responseString];
NSLog(@"Response: %@", responseString);
}];
[request setFailedBlock:^{
NSError *error = [request error];
NSLog(@"Error: %@", error.localizedDescription);
}];
[request startAsynchronous];
伊夫发现这个在互联网上,当我运行它,它失败,出现错误2012-01-17 10:52:16.939 MyApp[30373:707] Error: NSInvalidArgumentException
从很多,我在网上找到的文档和示例,这应该起作用,但它不是,正如你可以看到的例外。任何帮助消除扭结?如果您需要其他信息,我很乐意发布。
设置调试器停止异常,它停止的位置应该让你知道哪个参数是无效的。 – JosephH 2012-01-17 20:17:26