title: SharePoint 2013 file upload with Jquery
body: <p>I am currently developing a page which users will be able to upload from their local machines files to a sharepoint 2013 server.</p>
  
  <p>Currently I have managed to experiment with the ajax calls and use the rest api for creating simple .txt files and additional folders.</p>
  
  <p>The problem I am facing is a response I am getting when trying to upload a .doc file or any other file that is using an arrayBuffer as the data.</p>
  
  <p>Here is my code (which again is working is the data passed is a simple string:</p>
  
  <pre><code>url = "http://temp-sharepoint/_api/Web/GetFolderByServerRelativeUrl('Documents')/files/add(overwrite=true,url='"+fileName+"')";
  
              jQuery.ajax({
                  url: url,
                  type: "POST",
                  data: arrayBuffer,
                  processData: false,
                  headers: {
                      "Accept": "application/json; odata=verbose",
                      "X-RequestDigest": jQuery("#__REQUESTDIGEST").val(),
                       "content-length": arrayBuffer.byteLength
                  },
                 success: doSuccess,
                  error: onError
              });
  </code></pre>
  
  <p>The code above will result in a response of</p>
  
  <p>[object Error]{description: "The paramet...", message: "The paramet...", name: "Error", number: -2147024809, stack: "Error: The ..."}</p>
  
  <p>which is "The Parameter is incorrect."</p>
  
  <p>Again if data is "Test" the file is being created with no problems.</p>
  
  <p>I am quite new to sharepoint and I would appreciate if someone can point me to a possible solution.</p>
  
  <p>Thanks.</p>