Dear all, For a site I need a demo functionality. Long story short, I need people to be able to click a link which POST''s a file (which I, in this instance, provide). So far I''ve got: <%= link_to("Example", new_resource_path(:uploaded_data => "files/ some.pdf"), :method => :post, :multipart => true) %> Obviously this does not work as the :uploaded_data param contains a string and not the file. But I am at a loss on how to fix this. Any help is greatly appreciated. With kind regards, --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Don''t know if you can use path helpers for that, but: link_to("Example", "/docs/gebruikersovereenkomst.pdf") would work if the pdf is in the /docs folder below RAILS_ROOT --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Unfortunately I was a bit unclear in my initial post. What I want is to POST a file to a controller. So the user never sees the file. In effect I want to simulate a form with a file field, but with the file field already filled out. On Aug 25, 12:44 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> Don''t know if you can use path helpers for that, but: > > link_to("Example", "/docs/gebruikersovereenkomst.pdf") > > would work if the pdf is in the /docs folder below RAILS_ROOT--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hi, you could make a helper that writes a form something like that: <form action="whatever" name="myform" method="post"> <input type="hidden" name="a-hidden-field" value="field value" /> <a href="#" onclick="document.myform.submit();return false;">Your text</a> </form> but you should know that you can''t upload a file that hasn''t been previously selected through a file input due to security reasons. you could do this only when client and server are on the same machine... regards harm escribió:> Unfortunately I was a bit unclear in my initial post. What I want is > to POST a file to a controller. So the user never sees the file. In > effect I want to simulate a form with a file field, but with the file > field already filled out. > > On Aug 25, 12:44 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: > >> Don''t know if you can use path helpers for that, but: >> >> link_to("Example", "/docs/gebruikersovereenkomst.pdf") >> >> would work if the pdf is in the /docs folder below RAILS_ROOT >> > > >/** * dagi3d v4 - http://dagi3d.net */ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I was unaware of that fact. Hmmm. Makes a lot of sense though. Thanks for your suggestion! On Aug 25, 1:22 pm, Borja Martín <bor...-v796FXedN1GsTnJN9+BGXg@public.gmane.org> wrote:> hi, > you could make a helper that writes a form something like that: > <form action="whatever" name="myform" method="post"> > <input type="hidden" name="a-hidden-field" value="field value" /> > <a href="#" onclick="document.myform.submit();return false;">Your text</a> > </form> > > but you should know that you can''t upload a file that hasn''t been > previously selected through a file input due to security reasons. you > could do this only when client and server are on the same machine... > > regards > > harm escribió: > > > Unfortunately I was a bit unclear in my initial post. What I want is > > to POST a file to a controller. So the user never sees the file. In > > effect I want to simulate a form with a file field, but with the file > > field already filled out. > > > On Aug 25, 12:44 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: > > >> Don''t know if you can use path helpers for that, but: > > >> link_to("Example", "/docs/gebruikersovereenkomst.pdf") > > >> would work if the pdf is in the /docs folder below RAILS_ROOT > > /** > * dagi3d v4 -http://dagi3d.net > */--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---