I need help in upload multiple files using node.js upload file reader.
I am using the fs = require('fs').
I have problem in choose two files,only one file only write in upload directory.
This is my backend
var files = req.files.files[0];
for (var i = 0; i < files.length; i++) {
file = files[i];
fs.readFile(files[i].path, function(error, data) {
// console.log( files[i].path ) ,here displayed two same both
fs.writeFile(uploadDirectory() + newFileName, data, function(error) {
});
});
}
Please help me. what is the problem in my code. Thanks.
newFileNamebeing defined?