title: Send file with Angular and Django
body: <p>I'm doing a simple blog with Angular + Django. I have a page when the user can create a new post, writing the title and the body. In addition, at the end, he can add a file.</p>
  
  <p>This is the controller:</p>
  
  <pre><code>$scope.newPost = {};
  
  $scope.addPost = function(){
    if ($scope.newPost){
      PostListSrv.addPost.add($scope.newPost, function(data) {
          if (data) {
            console.log('success');
          }
        }, function(error) {
          if (error) {
            console.log('error');
          }
        }
      );
    } else {
  
            console.log('Error');
    }
  };
  </code></pre>
  
  <p>This is the service where I call the server:</p>
  
  <pre><code>   .....
    addPost: $resource('my_url', {
    }, {
      add: {
        method: 'POST',
        headers: { 'Content-Type': 'multipart/form-data' },
        params:{title:'title', text:'text', file: 'file'}
      }
    }), 
    ....
  </code></pre>
  
  <p>The problem is that if I try to add a new post, I get a 400 Error. In particular in the 'response' tab on 'Network' (Firefox) I have a red line that writes: SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data. How can I do?</p>