我在上传文件 nodejs 时遇到问题。我已阅读 stack1 和 stack2。但我认为终端输出的这种不同情况如下:
> Unhandled rejection Error: EXDEV: cross-device link not permitted,
> rename '/tmp/31941-53enly.png' ->
> 'public/files/complaint/Screenshot_2016-05-01_01-16-55.png'
> at Error (native)
> at Object.fs.renameSync (fs.js:681:18)
> at null.<anonymous> (/home/faris/myprojects/orchestrale-server/routes/complaintimage.js:163:20)
> at tryCatcher (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/util.js:16:23)
> at Promise._settlePromiseFromHandler (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:502:31)
> at Promise._settlePromise (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:559:18)
> at Promise._settlePromise0 (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:604:10)
> at Promise._settlePromises (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/promise.js:683:18)
> at Async._drainQueue (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/async.js:138:16)
> at Async._drainQueues (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/async.js:148:10)
> at Immediate.Async.drainQueues [as _onImmediate] (/home/faris/myprojects/orchestrale-server/node_modules/sequelize/node_modules/bluebird/js/release/async.js:17:14)
> at processImmediate [as _immediateCallback] (timers.js:383:17)
我的代码:
if (_.isEmpty(req.files) == false) {
var tp = avatar_folder+req.files.file.name;
fs.renameSync(req.files.file.path, tp, function(err){});
var avatar = req.files.file.name;
}
代码可以在基本操作系统等另一个发行版上运行,但是当我在 debian jessie 或 ubuntu 16 LTS 上运行项目时,终端上会出现错误。
任何身体都无法帮助?该代码在基本操作系统和拱门上完美运行。