title: FileUpload using Knockout in MVC
body: <p>I need to Upload all type of files using knockout js. I am using MVC 4.0 and i need to Save file separately in a folder. Once i have Uploaded File i need to show it in Grid(FileName, Date Created and Type of File).</p>
  
  <p>This is my View and Included the Knockout scripts. </p>
  
  <pre><code>var ViewModel = function () {
      var self = this;
      self.fileInput = ko.observable();
      self.fileName = ko.observable();
  
      var Data = {
  enter code here
          file: self.fileInput,
          FileName: self.fileName
      };
      self.save = function () {
          //Ajax call to Insert the Employee
          $.ajax({
              type: "POST",
              url: "/Home/FileUpload",
              data: ko.toJSON(Data),
              contentType: "application/json",
              dataType: 'json',
              //cache: false,
              mimeType: "multipart/form-data",
              //processData: false,
              success: function () {
                  alert("successful");
              },
              error: function () {
                  alert("fail");
              }
          });
      }
  
  }
  var vm = new ViewModel();
  ko.applyBindings(vm);
  
  
  
      &lt;html&gt;
        &lt;body&gt;
          &lt;div&gt;
      &lt;form method="post"&gt;
          &lt;span&gt;File&lt;/span&gt;
          &lt;input type="file" id="fileUpload" name="fileUpload" data-bind="file: {data: fileInput, name: fileName}" /&gt;
  
          &lt;input type="button" id="btnUpload" data-bind="click: save" value="Upload" formenctype="multipart/form-data" /&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><em><code>emphasized text</code></em></p>
  
  <p>So kindly help me out since i am new to knockout.</p>