AngularJS Example:
HTML
<div ng-app="app">
<div ng-controller="Ctrl">
<input ng-model="myFile" onchange="angular.element(this).scope().onchange(this.files)" type="file" />
</div>
</div>
JavaScript
var app = angular.module("app", []);
function Ctrl($scope) {
$scope.onchange = function (files) {
var file = files[0];
var reader = new FileReader();
reader.onload = function (e) {
//doing some stuff here
console.log(e)
//finally clear the file for new selection
$scope.myFile = null;
$scope.$apply();
};
reader.readAsText(file);
};
}