-(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 –