How to upload file by ajax

Hey’
How to upload file with ajax in ROR?
My code not working :frowning:
View file :
<% form_remote_tag(:url => { :controller => ‘Upload’, :action =>
‘uploadFile’},
:update => “result”,
:position => :bottom
:html => {:multipart => true} ) do %>

Choose file : :
<%= file_field ‘upload’, ‘datafile’, :size => ‘60’ %>


<%= submit_tag “Upload” %>
<% end %>

Controller :
def uploadFile
@post = DataFile.save( params[:upload])
if @post
render :partial => ‘data’, :object => @post
end
end

On Dec 8, 8:32 am, Nurzed L. [email protected]
wrote:

Hey’
How to upload file with ajax in ROR?

You can’t, because javascript doesn’t have access to the filesystem.
There’s a trick you can play with an invisible iframe, you should be
able to find it with a quick google.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs