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.

3
  • have a look stackoverflow.com/questions/31404502/… Commented Jun 6, 2017 at 5:42
  • 1
    Possible duplicate of Upload multiple files in angular Commented Jun 6, 2017 at 5: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. Commented Jun 6, 2017 at 5:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.