0

I want to use Cloudinary's service where I can upload files with their server side code.

But I don't understand how to get hold of the submitted file's path?

When a user chooses a file with a normal file input field, only the file name gets submitted with the form.

Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232

1 Answers1

1

We recommend to use our integration with CarrierWave or Attachinary. With CarrierWave, you'll be able to simply use something like:

<%= form_for model do |f| %>
  ...
  <%= f.upload_field :image %>

<% end %>

and everything else will be happening behind the scenes for you without any additional coding to do, as demonstrated in the sample project I shared previously.

If you still wish to do the coding on your end, then you can do something like the following:

<%= form_for model, html: {multipart: true} do |f| %>
  ...
  <%= upload_field_tag :image %>

<% end %>

then in your controller:

def create
  Cloudinary::Uploader.upload params[:image]
  ...
end
Itay Taragano
  • 1,901
  • 1
  • 11
  • 12