title: 'Unexpected token' in AJAX upload of multipart/form-data in angular.js 1.3.0
body: <p>The following code for texture upload was working in angularjs 1.2.26 but stopped working when I upgraded my web application to 1.3.0. </p>
  
  <p>HTML Code</p>
  
  <pre><code>&lt;input file-model="file" name="file" type="file"&gt;
  </code></pre>
  
  <p>fileModel Directive</p>
  
  <pre><code>app.directive('fileModel', [ '$parse', function($parse) {
      return {
          restrict : 'A',
          link : function(scope, element, attrs) {
              var model = $parse(attrs.fileModel);
              var modelSetter = model.assign;
  
              element.bind('change', function() {
                  scope.$apply(function() {
                      modelSetter(scope, element[0].files[0]);
                  });
              });
  
              scope.$on("reset", function() {
                  element.val(null);
              });
  
          }
      };
  } ]);
  </code></pre>
  
  <p>Upload Function - In 1.2.26 choosing "multipart/form-data" as Content-Type would not work. But with "undefined" as Content-Type angular would do some kind of magic that would make it work.</p>
  
  <pre><code>var upload = function(textureUploadUrl) {
          var formData = new FormData();
          formData.append('name', $scope.name);
          formData.append('file', $scope.file);
  
          $http.post(textureUploadUrl, formData, {
              transformRequest : angular.identity,
              headers : {
                  'Content-Type' : undefined
              }
          }).success(function(uploadedTexture) {
              console.log(uploadedTexture);
  
              // further processing of uploadedTexture
          });
  }
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>SyntaxError: Unexpected token h
      at Object.parse (native)
      at fromJson (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:1104:14)
      at defaultHttpResponseTransform (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:8572:18)
      at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:8517:12
      at forEach (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:335:20)
      at transformData (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:8516:3)
      at transformResponse (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:9224:23)
      at processQueue (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:12914:27)
      at https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:12930:27
      at Scope.$eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0/angular.js:14123:28) 
  </code></pre>
  
  <p>Does anyone know how to get this working in the new version?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've narrowed down the problem a little bit. It does not work with 1.3.0-rc.5, but with the previous version (rc.4) it does work. So, I'm currently trying to figure out which changes lead to my problem. Here is the <a href="https://github.com/angular/angular.js/blob/master/CHANGELOG.md">changelog</a>.</p>