How to read and write into file using JavaScript?

后端 未结 17 2713
孤街浪徒
孤街浪徒 2020-11-22 02:00

Can anybody give some sample code to read and write a file using JavaScript?

17条回答
  •  轮回少年
    2020-11-22 02:23

    To create file try

    function makefile(){
      var fso;
      var thefile;
    
        fso = new ActiveXObject("Scripting.FileSystemObject");
        thefile=fso.CreateTextFile("C:\\tmp\\MyFile.txt",true);
    
        thefile.close()
        }
    

    Create your directory in the C drive because windows has security against writing from web e.g create folder named "tmp" in C drive.

提交回复
热议问题