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!
I bet that you forgot to add to your form:
enctype="multipart/form-data"