convert image to base64 in angularjs

user2610160 picture user2610160 · Nov 13, 2014 · Viewed 50.9k times · Source

I have a requirement where user will upload their image and i have to convert it into something and send it to .Net REStful service. I am new to angular js. Could someone please help

Answer

Jaanus picture Jaanus · Nov 13, 2014

Answer from here https://stackoverflow.com/a/24880314/625189

I would recommend you to use https://github.com/ninjatronic/angular-base64.

After following instructions for using this library, you can simply call:

var imageData=$base64.encode(image);

Don't forget to inject in your module:

.module('myApp', ['base64'])