嘿,我正在尝试使用express-fileupload上传文件,但是无法将文件移动到我想要的其他项目中尝试的目录,该项目按预期工作,但是当前项目无法正常工作,
meetupImage.mv('files/images/',(error) => { /*
with this existing path it is not working , with non existing
path it is not working also however it works when i use
"anyname" But not a directory name*/
if (error) {
return res.status(500).json({ status: 500, error: `Failled to upload image ${error}`});
} else {
const sql = `INSERT INTO meetup_images_table (id, meetup, url) VALUES (1$, $2, 3$) RETURNING *`;
const newImage = [uuid.v4(),req.params.id, `images/uploaded/${meetupImage.name}`];
Database.executeQuery(sql, newImage).then((result) => {
if (result.rows) {
return res.status(201).json({ status: 201, data: result.rows });
}
}).catch(error => res.status(500).json({ status: 500, error: `Server Error ${error}`}));
return res.status(201).json({ status: 201, data: [meetupImage.name] });
}
});
Please hel pem
答案 0 :(得分:1)
哦,真的很抱歉,伙计们,我现在忘记添加文件名了!
原谅我我真的是一个初学者