Thursday, 18 May 2017

How to upload multiple files and generate unique path for every file using multer in node js

I'm trying to develop web application with javaScript,nodejs,mongoDB. I'm trying to upload multiple files in node js using multer npm package. below were he code i have tried till now. need more help on how to generate file path for each file

below is the code i have tried show far

var app       =   express();
var upload    =  multer({ dest: 'uploads/' });

app.post('/upload', upload.any(), function (req, res, next) {
  // req.body contains the text fields
     console.log(req.files);

    res.send('upload succeeded!');

})

have referred link Multer uploading array of files fail

please help me on how to generate file path for each uploaded file.

i have also used "conenct-busboy" as it was deprecated i have not using it any more.

I have successfully done with uploading file top folder and storing single file path and retrieving from mongoDB database.

Pleas help me in uploading multiple file and multiple file path storing in mongoDB

Thanks in advance.



via nikey

No comments:

Post a Comment