我想使用 fs.writeFile 保存圖像,但我做不到。我要執(zhí)行此操作的路徑:C:\Users\poz\lotos\images\1232133123@gmail.com我的代碼: var d = new Date(); var n = d.getTime() + ".jpeg"; var dir = "C:/Users/poz/lotos/images/" + email; mkdirp(dir); var data = image.replace(/^data:image\/jpeg;base64,/,''); var dir2 = dir + "/"; fs.writeFile(__dirname +'/../../images/' + email + '/' + n, data, 'base64' , function(err){ if (err) return console.log(err); });*文件夾已創(chuàng)建。我得到的錯(cuò)誤:[錯(cuò)誤:ENOENT:沒有這樣的文件或目錄,打開 'C:\Users\poz\lotos\images\1232133123@gmail.com\1602604489722.jpeg'] { 錯(cuò)誤號(hào):-4058,代碼:'ENOENT',系統(tǒng)調(diào)用:'打開',路徑:'C:\Users\poz\lotos\images\1232133123@gmail.com\1602604489722.jpeg'}
將文件保存在指定目錄 Node.js
滄海一幻覺
2023-05-11 16:08:04