johnyald
johnyald

Reputation: 53

Upload image from iOS?

I'm confused with uploading an image from iPhone, I don't know if I choose to to use base64encoding or multi-part data.

Upvotes: 1

Views: 139

Answers (3)

johnyald
johnyald

Reputation: 53

let theImg = imageview.image!
let imgrep = UIImageJPEGRepresentation(theImg, 0.5)
let b64 = imgrep!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)

let replaced = b64.stringByReplacingOccurrencesOfString("+", withString: "%2b")

Upvotes: 0

johnyald
johnyald

Reputation: 53

let theImg = imageview.image!
let imgrep = UIImagePNGRepresentation(theImg)

let b64 = imgrep!.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)

Upvotes: 0

Lotus Shah
Lotus Shah

Reputation: 493

Better to upload the base64 string on server so that you extract and get real image from the string on server.

otherwise both way is available to uploading image on server.

Upvotes: 1

Related Questions