I'm trying to rename a file, and I think I'm going mad my code is simple, I check if the file exists, and if it exists, I rename it. Here is the code :
if (fs.existsSync(__dirname+"/"+req.files.file.path))
{
fs.rename(__dirname+"/"+req.files.file.path, __dirname+"/app/upload/portfolio/video/"+req.files.file.name, function(err) {
if (err)
throw err;
else
....
});
}
But I get this error (I've replaced the realpath by path/to/file) :
throw err; ^ Error: ENOENT, rename 'path/to/file/filename.mp4'
After a check, I see that the file exists (simply by copy/paste the filepath in the error) What can be the reason of such an issue?