【发布时间】:2017-03-21 20:52:39
【问题描述】:
我正在尝试制作一个 API 来使用 Node.js 服务器上传文件。我收到了undefined 的回复。
我正在关注这个教程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 回复。
【问题讨论】:
标签: javascript html node.js file upload