Writing files in Node.js

前端 未结 19 2025
情歌与酒
情歌与酒 2020-11-21 11:57

I\'ve been trying to find a way to write to a file when using Node.js, but with no success. How can I do that?

19条回答
  •  礼貌的吻别
    2020-11-21 12:15

    You can use library easy-file-manager

    install first from npm npm install easy-file-manager

    Sample to upload and remove files

    var filemanager = require('easy-file-manager')
    var path = "/public"
    var filename = "test.jpg"
    var data; // buffered image
    
    filemanager.upload(path,filename,data,function(err){
        if (err) console.log(err);
    });
    
    filemanager.remove(path,"aa,filename,function(isSuccess){
        if (err) console.log(err);
    });
    

提交回复
热议问题