当我请求服务器上传和UImage时,我遇到了一个问题
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错误:没有上传文件
有人知道这件事吗,我做错了,
非常感谢你的帮助。
谢谢
发布于 2011-07-16 12:35:40
而不是
[request setData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"photo"];试着
[request addData:imageData withFileName:@"image.jpg" andContentType:@"image/jpeg" forKey:@"photo"];在ASIHTTPRequest的帮助下,我也做了同样的工作,并成功地将图片上传到服务器上。这应该能工作,我想,因为它是在我的一个现场项目工作。
https://stackoverflow.com/questions/6717326
复制相似问题