require,module.exports
require
module.exports
const userInsertInto = async(ctx, next) => {
var storage = multer.diskStorage({
//
destination: function(req, file, cb) {
cb(null, 'static/images/')
},
//
filename: function(req, file, cb) {
var fileFormat = (file.originalname).split(".");
cb(null, Date.now() + "." + fileFormat[fileFormat.length - 1]);
}
})
//
var upload = multer({ storage: storage }).single('file');
await upload(ctx)
.then(result => {
console.log(ctx.req.body);
console.log(ctx.req.file);
ctx.body = {
data: ctx.req.file
}
})
.catch(error => {
console.log(error)
ctx.body = false;
})
}
Previous: One query is a list, one query is details, how to better combine the two?
Next: How do I use the md5 () function to encrypt the primary key ID in a mysqli statement?