我在尝试使用Node.js服务器上传文件的API。我得到undefined
的回应。用HTML上传文件到Node.js
我下面这个教程https://www.youtube.com/watch?v=UtfZ-5WKpro
的Node.js:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.post("*", function(req, res) {
res.end(JSON.stringify(req.files) + "\n");
});
console.log("Server at 8080");
app.listen(8080);
HTML
<html>
<head>
<form method="post"
enctype="multipart/form-data"
action="http://localhost:8080">
<input type="file" name="myimage" />
<input type="submit" name="submit" value="submit"/>
</form>
</head>
</html>
点击提交我undefined
响应后。