How to copy a file in Node.js?
Example
+ /old
|- image.png
+ /new
I want to copy image1.png from \'old\' to \'new\' directory.
If you want to do this job syncronously, just read and then write the file directly:
var copyFileSync = function(srcFile, destFile, encoding) {
var content = fs.readFileSync(srcFile, encoding);
fs.writeFileSync(destFile, content, encoding);
}
Of course, error handling and stuff is always a good idea!