0
我有1個問題。不明白它是如何工作的。不工作createWriteStream和絕對路徑
我想在fs.createWriteStream
內創建文件,因此只適用於相對路徑。所有文件夾的創建
let p = path.resolve(`../uploads/${data.id}/${file.originalname}`).toString()
outStream = fs.createWriteStream(`./uploads/example.txt`,{flags:'w'}) //work
outStream = fs.createWriteStream(`${__dirname}/uploads/2/example.txt`,{flags:'w'}) //not work
outStream = fs.createWriteStream(p,{flags:'w'}) //not work
ENOENT:沒有這樣的文件或目錄,打開 '/Users/arsenkarapetan/Documents/sedalina/server/uploads/2/example.txt'
它如何糾正?也許我沒有權限?
是的,有點不正確的路徑 –