On Dec 8, 8:32 am, Nurzed Lkham
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
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
> @post = 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---