-(void)uploadUserImageWithUIImage:(UIImage *)image
{
UIImage *imageTanya = [UIImage imageNamed:@"1.jpg"];
AFHTTPRequestOperationManager *m = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:@"http://www.xxxxxxxx.com/yyyyyy/filesService.svc/"]];
NSData *imageData = UIImageJPEGRepresentation(imageTanya, 0.5);
AFHTTPRequestOperation *op = [m POST:@"UploadFile" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
//do not put image inside parameters dictionary as I did, but append it!
[formData appendPartWithFileData:imageData name:@"1" fileName:@"1.jpg" mimeType:@"image/jpeg"];
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@ ***** %@ **** %@", operation.responseString, responseObject, operation.request.URL.absoluteString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@ ***** %@", operation.responseString, error);
}];
[op start];
}
同时发送请求POST它变成GET因为AFNetworking当服务器重定向它发送错误的路径的方法已经变成得到 走错了路:“http://www.xxxxxxxx.com/UploadFile HTTP/1.1” 当我创建一个新项目,它工作正常,但在我的项目,它给了我这个错误 -xcode 5.1版 - AFNetworking 2.0AFNetworking发送GET而不是POST
它也发送GET –