On Dec 8, 8:32 am, Nurzed Lkham <[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
> My code not working :(
> View file :
> <% form_remote_tag(:url => { :controller => 'Upload', :action =>
> 'uploadFile'},
> :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
> [EMAIL PROTECTED] = DataFile.save( params[:upload])
> if @post
> render :partial => 'data', :object => @post
> end
> end
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---