通过multer上传图像时在postman中出现此错误
{
"error": {
"message": "ENOENT: no such file or directory, open 'D:\\adarsh\\API\\uploads\\2022-11-29T17:23:07.574Zdownload1.jpg'"
}
}
它的代码。
const multer = require("multer");
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './uploads/')
},
filename: function (req, file, cb) {
cb(null, new Date().toISOString() + file.originalname);
}
});
const upload = multer({storage: storage});
尝试写入上述代码
1条答案
按热度按时间i7uq4tfw1#
问题可能出在您提供目的路径的方式上,请尝试使用'/uploads'