ENOENT: no such file or directory .?

后端 未结 14 1553
梦谈多话
梦谈多话 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:37

    You should change the file name. Because ':' is not allowed in Windows.

    Eg:

    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);
        }
    });
    

提交回复
热议问题