1

I use ngFileUpload for upload files but it can upload only 1 file.

I want to upload and Image File and PDF File. How to upload multi file?

Help me please.

(function () {
    'use strict';
    var app = angular.module('pageApp', ['ngFileUpload']);

    app.controller('MyCtrl', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
        $scope.uploadPic = function (file) {
            file.upload = Upload.upload({

                url: 'save_form.php',
                data: {
                    file: file,
                    username: $scope.username
                },
            });

            file.upload.then(function (response) {
                $timeout(function () {
                    file.result = response.data;
                });
            }
        };

    }]);

})();
  <form name="myForm">    
      Profile Picture: <input type="file" ngf-select="" ng-model="picFile" name="file" ngf-accept="'image/*'">
      <br>
      Resume(.pdf): <input type="file" ngf-select="" ng-model="resumeFile" name="fileResume">
      <br>

      <button ng-disabled="!myForm.$valid" ng-click="uploadPic(picFile)">Submit</button>
  </form>

2
  • Do you mean you want to upload profile picture and resume both once? Commented Jan 20, 2017 at 17:37
  • Yes,I want to upload profile picture and resume both once. Commented Jan 20, 2017 at 18:22

1 Answer 1

1

If you want to upload multiple files at the same time you can combine those 2 input field and add multiple attribute to the input tag. Make sure your backend can accept multiple files / support the following features.

<form name="myForm">    
      Picture & Resume: <input type="file" ngf-select="" 
               ng-model="picFile" name="file"  ngf-pattern="'image/*,application/pdf'" multiple>
      <br>

      <button ng-disabled="!myForm.$valid" ng-click="uploadPic(picFile)">Submit</button>
  </form>
Sign up to request clarification or add additional context in comments.

Comments

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.