Skip to content

Instantly share code, notes, and snippets.

@dpogorzelski
Created October 15, 2013 12:43
Show Gist options
  • Save dpogorzelski/6991017 to your computer and use it in GitHub Desktop.
Save dpogorzelski/6991017 to your computer and use it in GitHub Desktop.
Client-side File Encryption: Frontend
//This directive handles multiple file selection and makes them available
// as an array to the onFile() function inside the controller
directives.directive('fileselect', ['$parse',
function($parse) {
return function(scope, elem, attr) {
var fn = $parse(attr['fileselect']);
elem.bind('change', function(evt) {
var files = [];
var fileList = evt.target.files;
for (var i = 0; i < fileList.length; i++) {
files.push(fileList[i]);
}
scope.$apply(function() {
fn(scope, {
files: files,
$event: evt
});
});
});
};
}
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment