I have an express app and using a form which takes a file as input. So in the formdata I get file URL like C:/fakepath/demo.jpgI have a function which is used to write this file to files directory in my app. Function goes like this :saveFile : function (filePath, cb) {let fileName = Date.now();let outputPath = __dirname + "/files/"+fileName+".jpg";fs.writeFile(outputPath, filePath, function (err) {if (err) {return cb(err);} else {return cb(null, constants.HOST_URL + outputPath);}});}This actually writes the file but it is empty. I want to write that file as jpg. How do I do that?
Submitted July 25, 2020 at 12:58PM by GhostFoxGod
No comments:
Post a Comment