I'm using this code but problem is that it encodes the Haxcode in nsdata conversion block I want to send same has code which I'm getting with userid which is 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 is making the URL connection in right way but response is server error.
First Convert UImage
to NSData
and from NSData to base64string and then pass that to your Webservice
finalImagePath = [imageData base64EncodedString];
NSString *strImageData = [finalImagePath stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];
and then send strImageData
to your webserivce.
While retriving from server use
NSString *strImageData = [finalImagePath stringByReplacingOccurrencesOfString:@"%2B" withString:@"+"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With