[英]req.files undefined in express.js
My goal is to upload to s3 without rely on any middle-where like multer.我的目标是上传到 s3,而不依赖于任何中间位置,例如 multer。 THis is my view:
这是我的观点:
<form role="form" action="/send" method="post">
<input type="file" name="photo" class="form-control"/>
<button type="submit">Submit</button>
</form>
My api using express.js:我的 api 使用 express.js:
router.post('/register_', function(req, res) {
console.log(req.files) // undefined
});
I do req.body.photo
it shows a string, but how do I stream the file if req.files
is undefined?我做
req.body.photo
它显示一个字符串,但是如果req.files
未定义,我如何流式传输文件?
First of all your html form is not proper.首先,您的 html 表单不正确。 There should be enctype="multipart/form-data" attribute to submit files from the form.
应该有 enctype="multipart/form-data" 属性来从表单提交文件。 Also I would suggest to use busboy in node application to accept files in a route.
另外我建议在节点应用程序中使用busboy来接受路由中的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.