我已使用 multer 將檔案上傳到臨時目錄
const imageStorage = multer.diskStorage({
// Destination to store image
destination: 'images',
filename: (req, file, cb) => {
cb(null, file.fieldname '_' Date.now()
path.extname(file.originalname))
fs.writeFile("/tmp/" file.originalname, message, function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
}
});
我怎樣才能洗掉它?
uj5u.com熱心網友回復:
您可以使用洗掉檔案
fs.unlink(path, (err) => {
if (err) throw err //handle your error the way you want to;
console.log('path/file.txt was deleted');//or else the file will be deleted
});
);
參考:https ://nodejs.org/api/fs.html
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/408024.html
標籤:
上一篇:XMLHttpRequest已被CORS策略阻止:預檢回應中的Access-Control-Allow-Headers不允許請求標頭欄位內容型別
