Skip to content

Instantly share code, notes, and snippets.

@AlexArchive
Created November 14, 2014 22:35
Show Gist options
  • Save AlexArchive/e68418f765dee2d86e35 to your computer and use it in GitHub Desktop.
Save AlexArchive/e68418f765dee2d86e35 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<script>
var app = angular.module('app', []);
app.controller('uploadController', function($scope) {
$scope.fileChanged = function (element) {
alert(typeof(element.files));
$scope.file = element.files[0];
$scope.$apply();
};
});
</script>
</head>
<body ng-app="app">
<form ng-controller="uploadController">
<input type="file"
onchange="angular.element(this).scope().fileChanged(this)"
ng-model="file"/>
{{ file.size }}
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment