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)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay