我要在Node Js Server中上传图像时添加ID

大家好,我想将ID和图像一起发送到ID和图像之间,然后将其与图像发送到Node JS Server,现在它仅通过API或Android应用程序发送图像,

var express = require ('express');
const app = express();

var fileupload = require('express-fileupload');
app.use(fileupload());

app.get ("/", (req,res,next) => {
    res.status(200).send("Hello World");
});

app.post("/upload", function(req,res,next){
    console.log(req.files);

    const id = req.id;
    const file = req.files.upload;
    console.log("ID"+ id);
    file.mv('./uploads/'+file.name, function(err, result){
        if(err)
            throw err;
        res.send({

            success : true,
            message : "File Uploaded!"
        });


    });
});

app.listen(3000, () => {
    console.log("Started on port : 3000");
})
评论