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