hi, I am porting an app from 1.2.5 to 2.0.2 and I am having problems with file uploads. The form fields look like this: <%= ''Add attachment''.t %>: <%= file_field ''attachments'', "upload#{id}", :size => ''40'' %> The old code expects params[:attachments]["upload#{i}"] to be an object (File?) with a method "original_filename". I am using ajax (and previously didn''t): <% form_remote_tag(:url => url_for(:controller => :mex, :action => :submit_answer, :id => mex_exercise.id), :update => "answer_#{mex_exercise.id}", :html => {:multipart => mex_exercise.num_attachments_allowed > 0}) do %> (num_attachments_allowed is > 0 and I see the enctype-attribute: <form action="/en/mex/submit_answer/46" enctype="multipart/form-data" method="post" onsubmit="new Ajax.Updater(''answer_46'', ''/en/mex/submit_answer/46'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this) + ''&authenticity_token='' + encodeURIComponent(''a5de291b429a9def0d4ff822d8e278172e472a28'')}); return false;"><div style="margin: 0pt; padding: 0pt;">) Do I need to change anything because of ajax? thanks, -- Felix Natter --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12 Feb 2008, at 14:22, Felix Natter wrote:> > hi, > > I am porting an app from 1.2.5 to 2.0.2 and I am having problems > with file > uploads. The form fields look like this: > > <%= ''Add attachment''.t %>: <%= file_field ''attachments'', > "upload#{id}", :size => ''40'' %> > > The old code expects params[:attachments]["upload#{i}"] to be an > object (File?) > with a method "original_filename". > I am using ajax (and previously didn''t): > > <% form_remote_tag(:url => url_for(:controller => :mex, :action > => :submit_answer, :id => mex_exercise.id), :update => > "answer_#{mex_exercise.id}", :html => {:multipart => > mex_exercise.num_attachments_allowed > 0}) do %> > > (num_attachments_allowed is > 0 and I see the enctype-attribute: > <form action="/en/mex/submit_answer/46" enctype="multipart/form- > data" method="post" onsubmit="new Ajax.Updater(''answer_46'', ''/en/mex/ > submit_answer/46'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this) + ''&authenticity_token='' + > encodeURIComponent(''a5de291b429a9def0d4ff822d8e278172e472a28'')}); > return false;"><div style="margin: 0pt; padding: 0pt;">) > > Do I need to change anything because of ajax?File uploads can''t be done over ajax (because the javascript isn''t allowed to read files from your computer). There are tricks you can play with iframes and so on. Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12 Feb 2008, at 15:22, Felix Natter wrote:> I am porting an app from 1.2.5 to 2.0.2 and I am having problems > with file > uploads. The form fields look like this: > > <%= ''Add attachment''.t %>: <%= file_field ''attachments'', "upload# > {id}", :size => ''40'' %> > > The old code expects params[:attachments]["upload#{i}"] to be an > object (File?) > with a method "original_filename". > I am using ajax (and previously didn''t): > > <% form_remote_tag(:url => url_for(:controller => :mex, :action > => :submit_answer, :id => mex_exercise.id), :update => "answer_# > {mex_exercise.id}", :html => {:multipart => > mex_exercise.num_attachments_allowed > 0}) do %> > > (num_attachments_allowed is > 0 and I see the enctype-attribute: > <form action="/en/mex/submit_answer/46" enctype="multipart/form- > data" method="post" onsubmit="new Ajax.Updater(''answer_46'', ''/en/ > mex/submit_answer/46'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this) + ''&authenticity_token='' + > encodeURIComponent(''a5de291b429a9def0d4ff822d8e278172e472a28'')}); > return false;"><div style="margin: 0pt; padding: 0pt;">) > > Do I need to change anything because of ajax?Indeed as another poster has already mentioned you can''t upload files through ajax (javascript security). Either use a Flash uploader like swfupload.org (but if you''re not fairly fluent in Javascript, i would advise against it), do know that the new session security measures cause problems if you want the upload to be authenticated or search for the responds_to_parent plugin and follow the instructions. Best regards Peter De Berdt --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I also use v2.0.2 and have problem with remote file upload. I followed the instructions from this page http://khamsouk.souvanlasy.com/2007/5/1/ajax-file-uploads-in-rails-using-attachment_fu-and-responds_to_parent and getting error undefined method `content_type'' in vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:260:in `uploaded_data anybody handled this problem in rails 2 ? Marek --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---