Node.JS fs.rename doesn't work Copying file from temporary folder to another partition gives error Just the same problem on windows (7) platform. Here is the form handler code I am using..
app.post('/contest/vacation-photo/:year/:month' , function(req, res){
var form = formidable.IncomingForm();
form.parse(req, function(err, fields, files){
if(err) return res.redirect(303, '/error');
if(err){
res.session.flash = {
type: 'danger',
intro: 'Oops!',
message: 'There was an error in processing your submission. ' +
'Please try again.',
};
return res.redirect(303, '/contest/vacation-photo');
}
var photo = files.photo;
var dir = vacationPhotoDir + '/' + Date.now();
var path = dir + '/' + photo.name;
fs.mkdirSync(dir);
fs.renameSync(photo.path, dir + '/' + photo.name);
saveContestEntry('vacation-photo', fields.email, req.params.year, req.params.month, path);
res.session.flash = {
type: 'Hurray',
intro: 'Good Luck!',
message: 'You have entered into the contest.',
};
return res.redirect(303, '/contest/vacation-photo/entries');
});
});
This is the error I am getting..
fs.js:638 return binding.rename(pathModule._makeLong(oldPath), ^ Error: EXDEV, cross-device link not permitted 'C:\Users\GARGAN~1\AppData\Local\T emp\upload_f6d504b9c38177d30e03ba2091e02168'