how to write a file on one controller and read the same in another controller in Node.js -


i want implement functionality in nodejs. have 2 different controllers in node application. has responsibility store file (abc.xlsx) local folder(mylocation) using fs module , have done successfully. , in controller have read locally stored file(abc.xlsx).

is possible. everytime want write file 1 controller , read same controller. have tried following..

exports.controller1 = function(req,res){  if(req.files.file){      fs.readfile(req.files.file.path,function(err,data){         var filename = req.files.file.name;         getfilename(filename);         logic goes here......      });  }  }   function getfilename(filename){       console.log(filename);  }  exports.controller2 = function(req,res){     getfilename(filename);     var filepath = filename;     logic goes here... } 

need filename or filepath read file

thanks in advance.


Comments