POST'ing a file with link_to

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,

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

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.

hi,

you could make a helper that writes a form something like that:

Your text

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.

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 - */

I was unaware of that fact. Hmmm. Makes a lot of sense though.
Thanks for your suggestion!