title: Saving Files to SQL server using knockout js
body: <p>I have a requirement on my web app to save multiple attachments to my SQL server. The attachments can be in any format. Is it possible to create a knockout viewmodel to encode the file type on client side to binary and transferring that binary info to my SQL server?</p>
  
  <p>I currently have this method in my REST service: </p>
  
  <pre><code>[OperationContract, WebInvoke(ResponseFormat = WebMessageFormat.Json)]
      public string PostAttachments (string  FileName)
      {
          try
          {
              var MyAttachment = new Binary(File.ReadAllBytes(FileName));
              return "Attachments Created";
          }
          catch (Exception ex)
          {
  
              return DefaultError + ex;
          }
  
      }
  </code></pre>
  
  <p>I know this is incorrect but I am really not sure how to do this file upload. I believe I am over complicating it. Any Assistance would be greatly appreciated.</p>