0

我使用 UIImagePickerController 的委托来选择照片并将其放到服务器上,但问题是我不知道如何使用 ASIFormDataRequest 来做到这一点,而且我不知道 info 参数应该使用什么键?

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

NSString *str = [NSString stringWithFormat:@"http://www.siteweb.com/api/v2/businesses/%@/pics.xml",entry.permalink];
NSURL *url = [NSURL URLWithString:str];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
request.delegate = self;

[request startAsynchronous];

[self dismissModalViewControllerAnimated:YES];
}
4

1 回答 1

1

像这样:

[请求 addFile:(NSString *)filePath forKey:(NSString *)key];

事先获取这样的图像:

UIImage *image = (UIImage *) [info valueForKey:UIImagePickerControllerOriginalImage];

[UIImageJPEGRepresentation(image, 1.0) writeToFile:filePath atomically:YES];

于 2012-01-10T01:58:11.147 回答