Forum: Ruby on Rails Uploading a file with form_remote_tag problem.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Chris R. (Guest)
on 2006-05-12 14:58
params[uploaded_file] is not recognised when i try form_remote_tag like
this:

<%=  form_remote_tag :url=>{:action => "save_file"} ,:html=>{:multipart
=> true}  	    <%=text_field_tag "name"%>
    <input type="file" id="uploaded_file_file"
name="uploaded_file[file]"/>
    <input type="submit" value="Upload" />
<%= end_form_tag %>

It works when i do a normal submit like so:

<%= form_tag( {:action => 'save_file'}, :multipart => true) %>
%>
	<%=text_field_tag "name"%>
    <input type="file" id="uploaded_file_file"
name="uploaded_file[file]"/>
    <input type="submit" value="Upload" />
<%= end_form_tag %>

Any ideas what is wrong?

Thanks in advance
Chris
Bryan D. (Guest)
on 2006-05-12 17:22
You can't upload a file through AJAX. It has to do with the fact that JS
can't access file upload fields directly.
This topic is locked and can not be replied to.