how to transfer multiples files and data to API in one request with angularjs

71 Views Asked by At

i have a angularjs form with data (name,surname,adress...) and multiple file upload. I use this to manage fileupload : https://github.com/nervgh/angular-file-upload

But what i want is to fill my form, choose files and just submit the form. I don't want to have to download files before submit the form.

but my files are uploaded after my data

how can i do for submit my form, upload files on server and if it's ok continue the treatment?

i tried this in my controller :

this.submit= function() {
    fileStore.uploader.uploadAll();
    //rest of my code
}

i also tried with OncompleteAll() function.

1

There are 1 best solutions below

0
sepointes On

i found solution to upload files and save data just after :

 this.submit= function() {

            $scope.uploader.uploadAll();
            $scope.uploader.onCompleteAll = function() {
               // the code to save data
            };
}