title: Uploading Files using AngularJS and symfony2
body: <p>I used the AngularJS example provided in <a href="http://jsfiddle.net/JeJenny/ZG9re/" rel="nofollow noreferrer">http://jsfiddle.net/JeJenny/ZG9re/</a> to upload a file from the local machine.
  I work with angularJS(frontend) and symfony2(backend),and I have to send an email attachement(as a rest web service) but I have a problem,I didn't get any email attachment,this is the error that I get in the console:</p>
  
  <p><img src="https://i.stack.imgur.com/eqJFq.png" alt="enter image description here"></p>
  
  <p>this is my code:</p>
  
  <pre><code>&lt;div ng-controller="MailNewCtrl1"&gt;
  &lt;input type="file" nv-file-select="" id="id_file"  uploader="uploader" file-model="myFile" &gt;
  &lt;button id="id_submit" class="btn btn-info w-xs" ng-click='usersend();'&gt;send&lt;/button&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and this the controller:</p>
  
  <pre><code>'use strict';
  
  angular.module('app', [
      'ngAnimate',
      'ngCookies',
      'ngResource'
  ])
  .controller('MailNewCtrl1', ['$scope', '$http' ,'fileUpload' , function($scope,$http,fileUpload) {
   $scope.errors = [];
        $scope.msgs = [];
        $scope.usersend = function() {
        $scope.errors.splice(0, $scope.errors.length); // remove all error messages
        $scope.msgs.splice(0, $scope.msgs.length);
         var file = $scope.myFile;
          console.log('file is ' + JSON.stringify(file));
          var uploadUrl = "/fileUpload";
          fileUpload.uploadFileToUrl(file, uploadUrl);
  
      $http({method: 'POST', url: 'theURLsendMail?myFile='+file}).success(function(data, status, headers, config){ 
       if (data.msg != '')
                          {
                              $scope.msgs.push(data.msg);
                              alert("sucess send");
                          }
                          else
                          {
                              $scope.errors.push(data.error);
                          }
                      }).error(function(data, status) { // called asynchronously if an error occurs
  // or server returns response with an error status.
                          $scope.errors.push(status);
                      });
  
          }
      }]);
  
  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]);
                  });
              });
          }
      };
  }]);
  
  app.service('fileUpload', ['$http', function ($http) {
      this.uploadFileToUrl = function(file, uploadUrl){
          var fd = new FormData();
          fd.append('file', file);
          $http.post(uploadUrl, fd, {
              transformRequest: angular.identity,
              headers: {'Content-Type': undefined}
          })
          .success(function(){
          })
          .error(function(){
          });
      }
  }]);
  </code></pre>
  
  <p>I even cheked the rights on the folder to store,it contains all the privilages</p>
  
  <p>thanks for help</p>