节点JS跨分区复制文件时出错。如何解决这个问题?

时间:2015-05-02 05:33:35

标签: javascript node.js git express

Node.JS fs.rename doesn't work 将文件从临时文件夹复制到另一个分区会出错 在Windows(7)平台上也是同样的问题。 这是我正在使用的表单处理程序代码..

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');
});
});

这是我得到的错误..

  

fs.js:638     return binding.rename(pathModule._makeLong(oldPath),                    ^   错误:EXDEV,不允许跨设备链接'C:\ Users \ GARGAN~1 \ AppData \ Local \ T   EMP \ upload_f6d504b9c38177d30e03ba2091e02168'

0 个答案:

没有答案