以下代码中的“upload.array('photos', 3)”是什么意思......
我的html代码。(为简洁起见,代码减少)
<form action="/upload" method="POST">
<input type="file" name="pic" id="pic" accept="image/*">
<input type="submit">
</form>
我的 expressjs 代码
AWS.config.update({
accessKeyId: "xxxxxxxxxxxxx",
secretAccessKey: "yyyyyyyyyy",
"region": "zzzzzzzzz" ,
signatureVersion: 'v4'
});
var s3=new AWS.S3();
var upload = multer({
storage: multerS3({
s3: s3,
bucket: 'imgcontainer',
metadata: function (req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key: function (req, file, cb) {
cb(null, Date.now().toString())
}
})
})
app.post('/upload', upload.array('photos', 3), function(req, res, next) {
res.send('Successfully uploaded ' + req.files.length + ' files!')
})
输出:
Cannot read property 'length' of undefined