I am posting data to a server from my ipad using json. But along with my data, i need to be able to send images aswell. I tried to add my image data to a dictionary and parse that into json, but json doesnt like nscfdata. What would be the easiest way i can post my images to the server? from other posts related to this topic, people have been converting to base64. Would i have to do that, or is there another easier or faster way? if i have to encode to base64 is there any tutorial on that?
            Asked
            
        
        
            Active
            
        
            Viewed 2,538 times
        
    1 Answers
6
            I convert it to base64. Check out this tutorial to get started!
http://www.cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html
Example:
NSImage *image = // some image
NSData *data = UIImagePNGRepresentation(image);
NSString *base64EncodedString = [data base64EncodedString];
You can then send the string via JSON.
 
    
    
        rocky
        
- 3,521
- 1
- 23
- 31
- 
                    can you share an example of how you convert image data as nsdata to base64 string? – hamza h Apr 26 '13 at 22:15
