NodeJs how to store an uploaded file using multiparty

1.4k Views Asked by At

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!!!");
 }
});
1

There are 1 best solutions below

1
Abdallah Safieddine On BEST ANSWER

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"}));