[英]req.files undefined in express.js
我的目標是上傳到 s3,而不依賴於任何中間位置,例如 multer。 這是我的觀點:
<form role="form" action="/send" method="post">
<input type="file" name="photo" class="form-control"/>
<button type="submit">Submit</button>
</form>
我的 api 使用 express.js:
router.post('/register_', function(req, res) {
console.log(req.files) // undefined
});
我做req.body.photo
它顯示一個字符串,但是如果req.files
未定義,我如何流式傳輸文件?
首先,您的 html 表單不正確。 應該有 enctype="multipart/form-data" 屬性來從表單提交文件。 另外我建議在節點應用程序中使用busboy來接受路由中的文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.