将文件上传到我的服务器后,我尝试将其移动到另一个文件夹(同一个磁盘),但出现错误
{[Error:ENOENT,rename 'F\myproject\1b231234nsdifhoi2323']
errno:34,
code:ENOENT,
path:'F\\myproject\\1b231234nsdifhoi2323'
}
我在窗户上并使用
app.use(express.bodyParser({
uploadDir:'./Temp'
}));
这是我的重命名代码
exports.upload = function(req, res,next){
console.log( req.body);
console.log(req.files);
var tmp_path = req.files.product_video.path;
var target_path = '\\Video\\' + req.files.product_video.name;
console.log(tmp_path); // Temp\1b231234nsdifhoi2323
console.log(target_path); // \Video\name
fs.rename(tmp_path, target_path, function(err) {
if (err) {
console.log(err)
};
fs.unlink(tmp_path, function() {
if (err){
console.log(err)
}else{
res.send('File uploaded to: ' + target_path + ' - ' + req.files.product_video.size + ' bytes');
}
});
});
};
看起来我弄错了路径,但我无法弄清楚!