Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 772 Bytes

readme.md

File metadata and controls

18 lines (14 loc) · 772 Bytes

Rails example for fileupload.js library

This is an example of Rails server code that saves attachment uploaded via ajax with fileuploaded.js library.

This code doesn't work at the moment properly with Safari, unless you specify a Content-Type in fileuploaded.js library. To do this add the following line: xhr.setRequestHeader("Content-Type", "application/octet-stream");

just before xhr.send(file).

You should have the following in fileupload.js:

    xhr.open("POST", this._options.action + queryString, true);
    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
    xhr.setRequestHeader("X-File-Name", encodeURIComponent(name));
    xhr.setRequestHeader("Content-Type", "application/octet-stream");
    xhr.send(file);