0

I'm using Koa-better-body with Koa2, and I want to handle single file uploads in a POST form submission (input type=file).

While all the other fields show up properly under ctx.request.fields, i.e. ctx.request.fields.title, my file input's contents simply aren't available!

Interestingly,under ctx.request.fields, I still get a value for my file input (ctx.request.fields.coverimage), but that only gives me a file-name string, not the actual file (a cover image in this case).

What am I missing!

Qasim
  • 1,554
  • 1
  • 13
  • 22

1 Answers1

1

I bet that you forgot to add to your form:

enctype="multipart/form-data"
Valera
  • 2,665
  • 2
  • 16
  • 33
  • This was it! Thanks :) I wanted to find out more, and these were good: - https://dev.to/sidthesloth92/understanding-html-form-encoding-url-encoded-and-multipart-forms-3lpa - https://stackoverflow.com/questions/4526273/what-does-enctype-multipart-form-data-mean – Qasim Dec 15 '18 at 09:34