ENOENT: no such file or directory .?

后端 未结 14 1589
梦谈多话
梦谈多话 2020-12-09 17:15

This is error which am getting while post data and file. I have followed \'academind\' tutorial for building Restful API services, also i have been searching answer for this

14条回答
  •  难免孤独
    2020-12-09 17:32

    I had a similar error and this is how I resolved it. After using the replace method, I changed './uploads/images/' to 'uploads/images'. In this case, multer created the folder automatically. So you have something like this

    const storage = multer.diskStorage({
        destination: function(req, file, cb) {
        cb(null, 'uploads/');
        },
        filename: function(req, file, cb) {
         cb(null, new Date().toISOString().replace(/:/g, '-')+ file.originalname);
          }
      });
    

    For Windows users.

提交回复
热议问题