title: Error: stream ended unexpectedly
body: <p>Am sending photo to the server side from the front-end to the back-end using ng-file-upload here is my code:</p>
  
  <p>View:</p>
  
  <pre><code>&lt;form name="photoForm" ng-submit="uploadPicture(files)"&gt;
      &lt;input type="text" class="form-control" value="Add Caption" ng-model="caption"&gt;
      &lt;input type="button" name="files" value="Upload picture" ngf-select ng-model="files" ngf-multiple="true" ngf-pattern="'image/*'"&gt;
      &lt;input type="submit" class="btn btn-default submitButton" ng-disabled="!photoForm.$valid"&gt;
      &lt;ul&gt;
        &lt;li ng-repeat="f in files" style="font:smaller"&gt;
          {{f.name}}{{f.$errorParam}}
        &lt;/li&gt;
      &lt;/ul&gt; &lt;/form
  </code></pre>
  
  <p>Controller: </p>
  
  <pre><code>// Upload Image
  $scope.uploadPicture = function(files){
  
    if (files &amp;&amp; files.length) {
        $scope.uploadFiles(files);
    }
  };
  
  $scope.uploadFiles = function(files){
     Upload.upload({
      url: '/api/posts/photo',
      method: 'POST',
      file: files
    }).then(function (response) {
          $timeout(function () {
              $scope.result = response.data;
          });
      }, function (response) {
          if (response.status &gt; 0) {
              $scope.errorMsg = response.status + ': ' + response.data;
          }
      });
  };
  </code></pre>
  
  <p>Route:</p>
  
  <pre><code>var  multipart = require('connect-multiparty'),
       multipartMiddleware = multipart();
  
  app.route('/api/posts/photo')
        .post(multipartMiddleware, photos.create);
  </code></pre>
  
  <p>Server:</p>
  
  <pre><code>exports.create = function(req, res){
  
    console.log(req.body, req.files);
  };
  </code></pre>
  
  <p>when ever I console.log(req.files), without the multipartMiddleware am able to see the file I uploaded, but once I add the multipartMiddleware the error message kept showing.  </p>