我正在使用ASIHttpRequest POST用戶並傳遞給執行php代碼的url。此代碼返回一個url字符串,但現在,還需要圖像才能在tableview中顯示它。如何使用ASIHttpRequest從iPhone上的URL保存圖像?ASIHttpRequest POST圖像
- (void)getData
{
activityIndicator.hidden = NO;
[activityIndicator startAnimating];
NSURL *url = [NSURL URLWithString:@"http://test.com/iphone.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
NSLog(@"URL = %@",url);
[request setValidatesSecureCertificate:NO];
[request setRequestMethod:@"POST"];
[request setPostValue:@"user1" forKey:@"user"];
[request setPostValue:@"admin" forKey:@"pass"];
[request setDelegate:self];
[request startAsynchronous];
NSString *response = [NSString stringWithContentsOfFile:
[request downloadDestinationPath] encoding:[request responseEncoding] error:nil];
}
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"Response %d ==> %@", request.responseStatusCode, [request responseString]);
[activityIndicator stopAnimating];
activityIndicator.hidden = YES;
}