JavaScript: delete, move, and copy files.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.