Forum: Ruby on Rails How to upload file by ajax

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Nuugii L. (Guest)
on 2008-12-08 10:32
How to upload file with ajax in ROR?
My code not working :(
View file :
<% form_remote_tag(:url => { :controller => 'Upload', :action =>
          :update => "result",
          :position => :bottom
           :html => {:multipart => true} ) do %>
    <p><label for="upload_file">Choose file :</label> :
    <%= file_field 'upload', 'datafile', :size => '60' %></p>
    <%= submit_tag "Upload" %>
    <% end %>

Controller :
def uploadFile
   @post = params[:upload])
   if @post
     render :partial => 'data', :object => @post
Frederick C. (Guest)
on 2008-12-08 10:55
(Received via mailing list)
On Dec 8, 8:32 am, Nurzed L. <removed_email_address@domain.invalid>
> 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.

This topic is locked and can not be replied to.