Following this example on how to upload files using AngularJS I can't figure out how this actually works.
As I understand the files are just displayed right after the choose section but they are never actually uploaded to the server it's self, if is that so ? If it is how do i change the code to save the files on server on a specific path ? If it is not some explanation on how this code works.
The html Code:
<div ng-controller="MyCtrl"> <div ng-repeat="step in stepsModel"> <img class="thumb" ng-src="{{step}}" /> </div> <input type='file' ng-model-instant onchange="angular.element(this).scope().imageUpload(event)" multiple /> </div> The JS:
var myApp = angular.module('myApp',[]); function MyCtrl($scope) { $scope.stepsModel = []; $scope.imageUpload = function(event){ var files = event.target.files; //FileList object for (var i = 0; i < files.length; i++) { var file = files[i]; var reader = new FileReader(); reader.onload = $scope.imageIsLoaded; reader.readAsDataURL(file); } } $scope.imageIsLoaded = function(e){ $scope.$apply(function() { $scope.stepsModel.push(e.target.result); }); } }