I use this code, but the problem is that it encodes Haxcode in the nsdata conversion block that I want to send has a code that I get with a user ID that is a fixed integer. Please help.
NSData *imageData = [NSData dataWithData:UIImageJPEGRepresentation(image1, 0)]; //image.image=image1; [Base64 initialize]; NSString *b64EncStr = [Base64 encode:imageData]; NSLog(@"encoded.%@",b64EncStr); NSURL *url = [[NSURL alloc] initWithString:updateimageURL]; NSMutableURLRequest *req = [[NSMutableURLRequest alloc]initWithURL:url]; [req setHTTPMethod:@"POST"]; NSString *trimmed = [b64EncStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; paramDataString = [NSString stringWithFormat:@"Id=%d&FromString=%@",100,trimmed]; NSLog(@"%@",paramDataString); NSData* aData = [paramDataString dataUsingEncoding:NSUTF8StringEncoding]; [req setHTTPBody: aData]; NSURLConnection *theConnection=[[NSURLConnection alloc]initWithRequest:req delegate:self]; if (theConnection) { NSMutableData *data = [[NSMutableData alloc] init]; self.receivedData=data; [data release]; } else { UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil message:@"Check your networking configuration." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; [alertView release]; } [url release]; [req release];
It makes the correct URL connection, but the answer is a server error.
source share