Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get Base64 image file from file input with Angular
app.directive("fileread", [function () {
return {
scope: {
fileread: "="
link: function (scope, element, attributes) {
element.bind("change", function (changeEvent) {
var reader = new FileReader();
reader.onload = function (loadEvent) {
scope.$apply(function () {
scope.fileread =;
<div class="form-group">
<input type="file" class="form-control" placeholder="Photo" fileread="">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.