【问题标题】:How can i upload Photo from imagePickerController using ASIFormDataRequest?如何使用 ASI FormData 请求从 uiimagePickerController 上传照片?
【发布时间】:2012-01-10 01:47:46
【问题描述】:

我使用 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];
}

【问题讨论】:

    标签: iphone cocoa-touch ipad asihttprequest asiformdatarequest


    【解决方案1】:

    像这样:

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

    事先得到这样的图像:

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

    [UIImageJPEGRepresentation(image, 1.0) writeToFile:filePath 原子地:是];

    【讨论】:

    • 我必须使用 imagePickerController 那么我可以为使用 info 参数的路径做什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    相关资源
    最近更新 更多