登录
注册
node.js 学习社区
关于文件上传的问题

路口

2020-12-21 18:21

var express = require('express');var formidable = require('formidable');var fs = require('fs');var app = express();app.post('/', (req, res) => { var form = new formidable.IncomingForm(); form.parse(req, (err, fields, files) => { fs.rename(files.imgs.path, './a.jpg', (err) => { console.log(err); }); });});

app.listen('6666', () => { console.log('ok');})

结果就是

[Error: EXDEV: cross-device link not permitted, rename 'C:\Users\z\AppData\Local\Temp\upload_9dda35b23ebed3fad36cc575855d9537' -> 'E:\newVscod\test_files\express_e\public\img\a.jpg'] {

errno: -4037,

code: 'EXDEV',

syscall: 'rename',

path: 'C:\\Users\\z\\AppData\\Local\\Temp\\upload_9dda35b23ebed3fad36cc575855d9537',

dest: 'E:\\newVscod\\test_files\\express_e\\public\\img\\a.jpg'

}



回复 · 1

发表回复

你可以在回复中 @ 其他人