0

MMy question is simple.I am trying to check upload file is there are not in folder using nodejs? If it there no need to allow ove the file in that folder otherwise need to move the file in that folder.I do not know how to check it?Any one know please help to find solution.

app.js:

app.post('/api/upload', multipartMiddleware, (req, res) => {

var tmp_path = req.files.uploads[0].path;
var target_path = './uploads/' + req.files.uploads[0].name;

fs.rename(tmp_path, target_path, function(err) {
    if (err) throw err;
    console.log("Upload started")
    fs.unlink(tmp_path, function() {
        if (err) throw err;
        res.send('File uploaded to: ' + target_path);
    });
}); 

});
Vimala K
  • 29
  • 1
  • 8

0 Answers0