Home > front end >  JS to local a TXT document write a line in the form of additional data?
JS to local a TXT document write a line in the form of additional data?

Time:10-01

JS to local a TXT document write a line in the form of additional data?

 
The function the download (filename, text) {
Var pom=document. The createElement method (" a ");
Pom. SetAttribute (" href ", "data: text/plain; The charset=utf-8, "+ encodeURIComponent (text));
Pom. SetAttribute (" download ", filename);
If (document. CreateEvent) {
Var event=document. CreateEvent (" MouseEvents ");
Event. InitEvent (" click ", true, true);
Pom. DispatchEvent (event);
}
The else {pom. Click (); }
}


I use this, but this name every time a new document, not additional written
Call FileSaver js, StreamSaver., js seems to also be seen within this document is automatically opened a document with the same belt (#)
How to add write?

CodePudding user response:

Additional, then delete the original file, modify the additional file name

CodePudding user response:

JS in browser front-end HTML page is not allowed to modify the user local files,
Can only is to generate a new file to let users download save (or browser automatically download to download the default directory),
Only in the server node. Js can, only change is the server files,
If it is in some of the C/S application in the HTML can also use the new ActiveXObject object (" Scripting. FileSystemObject "),

CodePudding user response:

Upstairs is, no doubt, and please post
(bosses still!)
  • Related