title: ASP.NET MVC 3 - File upload through AngularJS
body: <p>I'm using <a href="http://angularjs.org/" rel="nofollow">AngularJS</a> with my pages, and I have a doubt: when I do post with my form, how can I pass some selected file to my ASP.NET MVC 3 Controller?
  Check this out:</p>
  
  <p>My form:</p>
  
  <pre><code>&lt;form enctype="multipart/form-data" ng-controller="FilesController" ng-submit="submitingForm()"&gt;
      &lt;div&gt;
          Choose the file:
          &lt;input type="file" onchange="angular.element(this).scope().setSelectedFile(this)" /&gt;
      &lt;/div&gt;
  
      &lt;input type="submit" value="Confirm" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And the AngularJS Controller:</p>
  
  <pre><code>var module = angular.module('application', []);
  
  (function (ang, app) {
  
      function FilesController($scope, $http) {
  
          $scope.setSelectedFile = function (element) {
              $scope.$apply(function($scope) {
                  $scope.selectedFile = element.files[0];
              });
          };
  
          $scope.submitingForm = function() {
  
              $http.post(url, ???????).success(function() {
                  // How to pass that selected file for my ASP.NET controller?
              });
          }
      }
  
      app.controller("FilesController", FilesController);
  })(angular, module);
  </code></pre>
  
  <p>Thank you!!!</p>