I have a form in which someone could upload a file, and then undo if they don't want it anymore. I want to send a request to the server to delete the file, but I'm afraid the user might send ../../lorem/ipsum/
. I have a csrf token in the header and a session.id as a cookie, but how would I use them? I have to use DELETE as the request method.
revert = function(req, res) {
fs.unlink(`/home/node/` + req.body.file, (err) => {
if (err) throw err;
console.log('file was deleted');
});
res.send('done');
};
app.delete('/revert', revert);