node.jsmultiparty

NodeJs how to store an uploaded file using multiparty


I'm trying to store an uploaded file,the file reached the server successfully but don't know how to store it using the multiparty library that's the code:

    var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
app.post('/upload_audio', multipartMiddleware, function(req, resp) {
  console.log(req.body, req.files);
 if(req.files){
     resp.status(200).send("Uploaded!!!");
 }
});

Solution

  • By default the 'connect-multipart' module save the file in a default file which is
    "C://Users//ur-username//AppData//Local//Temp" but you can change it by adding this line :

    app.use(multipart({ uploadDir: "ur_path"}));