Upload multiple images AngularJS

0

How about, I ask for your help, I want to select images in a single load, that is to say that the user chooses if he wants to upload a single image or more than one. I'm doing it in the following way:

app.controller('ImagesCtrl', function ($scope, $timeout, $location, $window, $firebaseObject, $firebaseArray) {
    'use strict';
    window.scrollTo(0, 0);
    const REF = firebase.database().ref();

    
        $scope.thumbnail = {
        dataUrl: 'adsfas'
    };
    $scope.fileReaderSupported = window.FileReader != null;
    $scope.photoChanged = function(files){ 
        if (files != null) {
            for(let i=0; i>files.length; i++){
            let file = files[i];
            if ($scope.fileReaderSupported && file.type.indexOf('image') > -1) {
                $timeout(function() {
                    let fileReader = new FileReader();
                    fileReader.readAsDataURL(file);
                    fileReader.onload = function(e) {
                        $timeout(function(){
                            $scope.thumbnail.dataUrl = e.target.result;
                            console.log(e.target.result);
                        });
                    }
                });
            }
        }
        }
    };

});
});
<input type="file" name="file" onchange="angular.element(this).scope().photoChanged(this.files)" multiple/>
        <img ng-src="{{ thumbnail.dataUrl }}"/>

The problem is that it only brings me the first image that I select, I am trying to go to an arrangement and then save them in firebase. Thank you very much!

    
asked by Checo 15.12.2017 в 02:00
source

0 answers