I am working with node and express and i have a directory structure like
public
img
css
js
server.js
in server.js i have the following code for writing to a png file
fs.writeFile('testfile.png', imageData, function(err){
res.send("file successfully created");
});
this creates the file in the root i.e. with the following directory structure
public
img
css
js
server.js
testfile.png
How do I create testfile.pnginside the img directory? simply using img/testfile.png, /img/testfile.png or /public/img/testfile.png does not work-- no file is created.
Help appreciated!