Questions about koa-router,module.exports exporting fn, to router.post ('/ url', fn))

< H2 > implement a picture upload and form data submission, but there is a problem < / H2 >

clipboard.png


clipboard.png

require,module.exports

require


module.exports


clipboard.png

clipboard.png

Mar.20,2021

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;
        })
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e599ef-45550.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e599ef-45550.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?