我收到此错误消息:错误:EXDEV:不允许跨设备链接,重命名为'/ tmp / upload_28ccb32e4096c7647d7318d3d3dd416f'->'./public/uploadDir/2970cda49b59328521550a4240f36b4e.jpg' 错误(本机)。
代码:
router.post('/', eformidable(), (req, res) => {
const hash = c.createHash('md5');
MongoClient.connect(url, { useNewUrlParser: true }, (err, db) => {
if (err) throw err;
const dbo = db.db('Database');
// Find all documents in the customers collection:
dbo.collection('HouseAds').find({ _id: req.body.LID }, (err2, result) => {
if (err2) throw err2;
/* if the ID is valid and was found in the database. */
if (result != null) {
// console.log(req.files);
const fileHandler = req.files.kep;
const nameOfImage = `${hash.update(fileHandler.toJSON.toString() + Date().toString()).digest('hex')}.jpg`;
const pathOfImage = `./public/uploadDir/${nameOfImage}`;
fs.rename(fileHandler.path, pathOfImage, (error) => {
if (error) {
res.status(500).send('hooooooooops.');
throw error;
}