ng-file-upload + sending multiple file array empty to server (sails)
<p>I am trying to send multiple files to my sails server using ng-file-upload . I'm using the example of ng-file-upload's webpage, and it does not work.</p>

<p><strong>Problem:</strong></p>

<p>I get an empty array at the server.</p>

<p><strong>Facts:</strong></p>

<p>I am using chrome and it has html5 multiple file upload support.</p>

<p>I tested the server using postman and it worked, that being said, the problem is with the client.</p>

<p>I'm able to console.log the files at the client.</p>

<p>Here is the js code:</p>

<pre><code>$scope.onFileSelect = function (files) {
         if (!($scope.updateAssetForm.OSGImages)) {
             console.log($scope.updateAsset.OSGImages.$valid);
             console.log($scope.updateAssetForm.OSGImages);
             return;
         }
        console.log($scope.updateAssetForm.OSGImages);
        var test = [];
        for (var i = 0; i &lt; $scope.updateAssetForm.OSGImages.length; i++) {
            test.push($scope.updateAssetForm.OSGImages[i])
        }
        console.log(test);


                Upload.upload({
                    url: '/api/updateAsset',
                    data: {
                         osgFile: test,
                        'assetId': 5,
                        'loadValueType' : 4,
                    }
                })


    },
</code></pre>

<p>Here is the html code:</p>

<pre><code>&lt;div class = "control-group form-group col-md-12"
    ng-class = "{'has-error':updateAsset.OSGImages.$invalid &amp;&amp; updateAsset.OSGImages.$dirty}" ng-if = "showUploadFile(4)"&gt;
      &lt;button ngf-select="onFileSelect(updateAssetForm.OSGImages)" ng-model="updateAssetForm.OSGImages" ngf-multiple="true"&gt;
      OSG Images (optional) (max 3 MB) 
      &lt;/div&gt;
      &lt;p ng-repeat="image in updateAssetForm.OSGImages"&gt;
        {{image.name}}
      &lt;/p&gt;
      &lt;span class = "help-block has-error" ng-if="updateAsset.OSGImages.$dirty"&gt;
      &lt;/span&gt;
    &lt;/div&gt;
</code></pre>

<p><strong>Network Tab log:</strong></p>

<p>Accept:application/json, text/plain, <em>/</em>
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryhfBw31xYfdWDtTlU
Origin:<a href="http://localhost:1337" rel="nofollow">http://localhost:1337</a>
Referer:<a href="http://localhost:1337/editproject" rel="nofollow">http://localhost:1337/editproject</a>
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36</p>

<p>------WebKitFormBoundaryhfBw31xYfdWDtTlU
Content-Disposition: form-data; name="osgFile[0]"; filename="p51d-jw-03.png"
Content-Type: image/png</p>

<p>------WebKitFormBoundaryhfBw31xYfdWDtTlU
Content-Disposition: form-data; name="osgFile[1]"; filename="p51d-jw-02.png"
Content-Type: image/png</p>

<p>------WebKitFormBoundaryhfBw31xYfdWDtTlU
Content-Disposition: form-data; name="osgFile[2]"; filename="p51d-jw-01.png"
Content-Type: image/png</p>

<p>------WebKitFormBoundaryhfBw31xYfdWDtTlU
Content-Disposition: form-data; name="assetId"</p>

<p>5
------WebKitFormBoundaryhfBw31xYfdWDtTlU
Content-Disposition: form-data; name="loadValueType"</p>

<p>4
------WebKitFormBoundaryhfBw31xYfdWDtTlU--</p>

<p>What I'm doing wrong?</p>