I am getting this error and I have no idea why its giving me that error, I have checked all the tutorials/similar questions related to this and nothing has worked. Can someone please help point me in the right direction.
Thank you,
Error:
Unexpected field
Error: Unexpected field
at makeError (C:\Users\Administrator\Desktop\express-cc-master\node_modules\multer\lib\make-error.js:12:13)
at wrappedFileFilter (C:\Users\Administrator\Desktop\express-cc-master\node_modules\multer\index.js:40:19)
Profile.js
var aws = require('aws-sdk')
var express = require('express');
var router = express.Router();
var multer = require('multer')
var multerS3 = require('multer-s3')
aws.config.loadFromPath('./config.json');
aws.config.update({
signatureVersion: 'v4'
});
var s3 = new aws.S3({});
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'raytestbucket123',
acl: 'public-read',
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, Date.now()+file.originalname)
}
})
})
router.get('/profile', function(req, res){
res.render('profile', { title: 'Profile' });
});
router.post('/profile', upload.single('file'), function(req, res, next){
res.send(req.files);
console.log(req.files);
})
module.exports = router;
Profile.hbs
{{> header }}
<body>
<form action="/profile" method="POST" enctype="multipart/form-data">
File to upload to S3:
<input name="file" type="file">
<br>
<input type="submit" value="Upload File to S3">
</form>
</body>
<div class="container">
<h2>Profile</h2>
</div>