Answer the question
In order to leave comments, you need to log in
How to upload file to server without using form helpers?
I'm using ruby-hyperloop , because of which the client code is written in .rb files, so the form for uploading files to the server must be executed without helpers, which are only available for Action View.
FORM(action: '/library', method: 'post') do
INPUT(name: 'book_file', type: 'file')
BUTTON(type: 'submit') { 'Upload' }
end
<form action="/library" method="post">
<input name="book_file" type="file" />
<button type="submit">Upload</button>
</form>
def create
book_file = params[:book_file].inspect
puts '------------'
puts book_file
puts '------------'
...
end
Answer the question
In order to leave comments, you need to log in
It's not about the helpers, it's about the form itself. She also needs to specify enctype="multipart/form-data"
Read more about the enctype attribute on htmlbook
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question