JavaScript: delete, move, and copy files.
This example describes how to delete, move, and copy files in JavaScript. Share it with you for your reference. The details are as follows:
Here, we use javascriptto Delete and copy files. Before running, ensure that the file already exists. For example, if you create the test.txt file on the C drive, modify it to this path in the code, and then run the code to see the effect.
<Html>
Supplement:
New ActiveXObject ("Scripting. FileSystemObject:
When you use JScript to read and write local files, the Scripting. FileSystemObject control is used.
By default, IE does not allow running such ActiveX controls that are not marked as secure script execution.
Therefore, when executing the downstream code:
Fso = new ActiveXObject ("Scripting. FileSystemObject ");
The exception "The Automation server cannot create objects" is thrown.
Solution:
IE-> Internet Options-> Security-> Custom Level-> ActiveX controls and plug-ins-> initialize and execute scripts for ActiveX controls that are not marked as secure scripts (Insecure) -> enable
Note:
Enabling this option can only be used to debug local code. Remember to change it before accessing other websites.
Otherwise, the malicious script will have all the permissions to read, write, and traverse your local files through IE !!!
I hope this article will help you design javascript programs.