首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASIFormDataRequest返回误差

ASIFormDataRequest返回误差
EN

Stack Overflow用户
提问于 2011-07-16 12:23:30
回答 1查看 286关注 0票数 0

当我请求服务器上传和UImage时,我遇到了一个问题

代码语言:javascript
复制
    NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/image.jpg"]; //UIImage *img = pickerImage;
    [UIImageJPEGRepresentation(postingImage, 0.5) writeToFile:jpgPath atomically:YES];
    NSData *imageData = UIImageJPEGRepresentation(postingImage, 0.5);
    NSURL *url = [NSURL URLWithString:serverURL];
    ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

    [request setData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

    [request startSynchronous];
    NSLog(@"responseStatusCode %i",[request responseStatusCode]);
    NSLog(@"responseStatusString %@",[request responseString]);

它给出了这样的回应

responseStatusCode 200

responseStatusString错误:没有上传文件

有人知道这件事吗,我做错了,

非常感谢你的帮助。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2011-07-16 12:35:40

而不是

代码语言:javascript
复制
[request setData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

试着

代码语言:javascript
复制
[request addData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"photo"];

在ASIHTTPRequest的帮助下,我也做了同样的工作,并成功地将图片上传到服务器上。这应该能工作,我想,因为它是在我的一个现场项目工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6717326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档