Rails 3 Can't Upload with AJAX -
so need upload files via ajax... have both parts working seperately.... upload view: <%= form_tag('upload_zip', :multipart => true) %> <p> file:<br /> <%= file_field_tag 'zip_file' %><br /> </p> <p> <%= submit_tag "upload zip/tar.gz" %> </p> <% end %> , else have remote form_tag working... <%= form_tag url_for(:action => :add_tracks), :remote => true %> ..... <%= submit_tag "submit", :disable_with => "processing..." %> both of these work fine when try add :remote => true can't seem work. of syntaxes seem not file name , try upload nil.
file uploads tricky. i'd recommend using uploadify. there example of how here: https://github.com/rdetert/formfly
the other thing watch out protect_from_forgery rails uses. there fix not long ago needed include in application.js ajax requests work in:
$(document).ajaxsend(function(e, xhr, options) { var token = $("meta[name='csrf-token']").attr("content"); xhr.setrequestheader("x-csrf-token", token); });
Comments
Post a Comment