我在嘗試使用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
響應後。