1

I am developing angularjs application where I have multiple file upload dynamically. Let me explain the scenario. I will get required list of documents in API. I will bind as below.

  <div class="upload-button" ng-repeat="file in files">
      <div class="upload-button-icon">
           <img src="images/folder-small.png">
           <div class="upload-text">{{file}}</div>
           <input type="file" id="file1" name="file1"  />
      </div>
  </div>

  <div class="button-container margin-top80">
       <input type="submit" value="{{ 'Save' | translate }}" ng-click="uploadFiles()" class="blue-button">
  </div>

I have tried as below.

$scope.upload = function () {debugger;
        alert($scope.files.length + " files selected ... Write your Upload Code");
        var fileuploadurl = baseurl + 'api/Customer/UploadLeaseFiles/' + LoginID + '/' + "GOSI";
        for (var i = 0; i < $scope.files.length; i++) {
            var $file = $scope.files[i];
                 $upload.upload({
                 url: fileuploadurl,
                 file: $file,
                 progress: function (e) {
                 // wait...
             }
          })
         .then(function (data, status, headers, config) {
            alert('file is uploaded successfully');
         });
      }
     alert('file is uploaded successfully');
 };

This code is giving me error eferenceError: $upload is not defined.

I want to submit these files to API. May I know how can I do this? Any help would be greatly appreciated. Thank you.

gorkem
  • 731
  • 1
  • 10
  • 17
Niranjan Godbole
  • 2,135
  • 7
  • 43
  • 90
  • have a look https://stackoverflow.com/questions/31404502/upload-multiple-files-in-angular – abhit Jun 06 '17 at 05:42
  • 1
    Possible duplicate of [Upload multiple files in angular](https://stackoverflow.com/questions/31404502/upload-multiple-files-in-angular) – NiRUS Jun 06 '17 at 05:46
  • Thank you. I tried same way. Finally ended up with eferenceError: $upload is not defined error. May i know why i am getting this error. Thank you. – Niranjan Godbole Jun 06 '17 at 05:56

0 Answers0