I have got the following problem:

I am using ng-file-upload to post files to my backend. I have setup the 
drop area to show up via ng-if when someone hit the a button. This works 
perfectly I can select a file and I also see the name of it like in the 
demo of ng-file-upload. The user should now be able to upload this file 
when hitting save but everytime he does that angular tells me that the 
files are undefined.

Here my upload and save method:

Upload:

  $scope.upload = function (files) {
        console.log($scope.files);
    if ($scope.files && files.length) {
        for (var i = 0; i < files.length; i++) {
            var file = files[i];
            $upload.upload({
                url: base+'/doc/'+$scope.project_id+'?name='+$scope.doc.name,
                                    method: 'POST',
                doc: file
            }).progress(function (evt) {
                var progressPercentage = parseInt(100.0 * evt.loaded / 
evt.total);
                console.log('progress: ' + progressPercentage + '% ' +
                            evt.config.file.name);
            }).success(function (data, status, headers, config) {
                console.log('file ' + config.file.name + 'uploaded. Response: ' 
+
                            JSON.stringify(data));
            });
        }
    }};

Save:

$scope.saveDoc = function(){
    console.log($scope.files);}

I cannot think of a reason why files should be empty since the ng-repeat in 
the frontend works.

<div ng-file-drop ng-file-select ng-model="files" class="drop-box"
      drag-over-class="dragover" ng-multiple="true" allow-dir="true">Drop pdfs 
or images here or click to upload</div>
  <div ng-no-file-drop>File Drag/Drop is not supported for this browser</div>
  <ul>
    <li ng-repeat="f in files" style="font:smaller">{{f.name}}</li>

It shows me the name perfectly.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to