0

i Have the local path of image in xcode and i want it to covert the image into base64 and send it to the php file.

Tha path is

/var/mobile/Applications/DC455F71-2024-473A-A943-504D0FC39C9F/Documents/1_1.png

Please help me to convert the image on the above path to convert it base64 encoding and then store it in remote mysql database.

Anbu.Karthik
  • 82,064
  • 23
  • 174
  • 143
Demo Ashish
  • 110
  • 1
  • 9
  • Possible duplicate [convert-image-to-base64-string-in-ios-swift](http://stackoverflow.com/questions/11251340/convert-image-to-base64-string-in-ios-swift/11251478#11251478) – Paresh Navadiya Nov 24 '14 at 07:39

1 Answers1

0

Download NSData+Base64 category, and add it to your project.
After that in your Controller for example.

#import "NSData+Base64.h"
.....
NSString *base64 = [[NSData dataWithContentsOfFile:path] base64EncodedString];
// Request and send your base64 string to server, as usual you're sending another string

Or if your deployment target is iOS7+, use this

NSString *base64 = [[NSData dataWithContentsOfFile:path] base64EncodedString];
// Request and send your base64 string to server, as usual you're sending another string
l0gg3r
  • 8,864
  • 3
  • 26
  • 46