When I submit a multi-part form,
<form name="acount_manage" action="/update" enctype="multipart/form-data" method="post"> <input type="file" name="file"> </form>
He throws out:
Error: Unsupported content-type: multipart/form-data at Object.<anonymous> (e:\...\node_modules\co-body\lib\any.js:51:15)
any.js:
var json = require('./json'); var form = require('./form'); var text = require('./text'); var JSON_CONTENT_TYPES = [ 'application/json', 'application/json-patch+json', 'application/vnd.api+json', 'application/csp-report', 'application/ld+json' ]; module.exports = function(req, opts){ req = req.req || req;
then i changed the code
if ('application/x-www-form-urlencoded' == type) return form(req, opts);
to
if ('application/x-www-form-urlencoded' == type || 'multipart/form-data'==type) return form(req, opts);
there is no error, but I can not get the request data:
debug(this.request.files.file);
The result is undefined.
I am using KoaJs.
source share