I’d tried the following
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
imagedata = UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"],1);
NSString *s1 = [[[NSString alloc]initWithData:imagedata encoding:NSUTF8StringEncoding]autorelease];
NSString *s2 = [[[NSString alloc] initWithBytes:[imagedata bytes]
length:[imagedata length] encoding: NSUTF8StringEncoding]autorelease];
NSString *s3 = [NSString stringWithUTF8String:[imagedata bytes]];
[picker dismissModalViewControllerAnimated:YES];
}
if I see the Printing description of imagedata: in Debugger Console,I can see the blob value there.
But I cant get that in NSString , all the above s1,s2,s3 returns null value.
I want to upload the blob value of the image to remote server database.
What’s The solution for it?
You are trying to convert image into NSString using various encoding methods which will return you null because you can not convert UIImage to NSString.
The alternative is to use base64 encoding function to convert into NSString
Add this piece of code in your class:
and then use following statement to convert into NSString: