Skip to content

Rails server side example of using fileuploader with Rails. Files are saved with has_attachment

Notifications You must be signed in to change notification settings

vohtaski/fileuploader_and_rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

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);

About

Rails server side example of using fileuploader with Rails. Files are saved with has_attachment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published