DEV Community

wusher
wusher

Posted on • Originally published at wusher.github.io on

File Uploads Without Form Helpers

When uploading files without using the form helper form.file_field, you have to add the option multipart: true to the form tag.

Discovered in API Docs

  < %= form_with(model: @company), multipart: true) do |form| %>

    -- When using: --
    <input type="file" name="company[logo]" />
    -- OR --
    < %= file_field_tag "company[logo]" %>

    < %= form.submit %>
  < % end %>

Enter fullscreen mode Exit fullscreen mode

Top comments (0)