我試圖存儲到新創建的目錄的圖像,在第一次嘗試它的正常工作,但在未來,並進一步嘗試它顯示了以下錯誤:我無法保存文件目錄
C:\testing\file.js:48
if(err) throw err
Error: ENOENT: no such file or directory,
open 'C:\testing\hello\images\pic.jpg'
at Error (native)
我的代碼是:
const dir ='./'+hello+'/images'
if (!fs.existsSync(dir)){
mkdirp(dir, function (err) {
if (err) throw err
})
}
fs.writeFile(dir+'/pic.jpg',base64 string, {encoding: 'base64'}, function(err) {
if(err) throw err
console.log('File created')
});
我真的不明白你在說什麼,如果你能給出一個示例代碼對我有幫助 –