连接多方中间获取文件请求未定义
我试图通过connect-multiparty
将图像file upload到服务器
router.post('/image', multipartMiddleware , function(req, res) { console.log(req.body, req.file); }); <form method="post" action="/products/image"> <input type="file" name="file"> <input type="submit" value="Upload"> </form>
但上面的控制台的结果是{ file: '156.jpg' } undefined
,即我可以得到的文件名,但为什么文件对象不来?
文件内容位于代码中的req.files
而不是req.file
中。
并且还可以find文件path和文件名
var tmppath = req.files.file.path; var tmpname = req.files.file.name;
这里是一个链接 ,我用Node.js
上传文件。