JavaScript implements the method of deleting, moving, and copying files _javascript tips

Source: Internet
Author: User

This example describes the way JavaScript implements deleting, moving, and copying files. Share to everyone for your reference. Specifically as follows:

Here use JavaScript to delete, move and copy files, before running please make sure that the file already exists, such as in the C disk to create Test.txt file, and then modify it in the code to this path, then run the code, you can see the effect.

 
 

Add:

The workaround for throwing an exception when new ActiveXObject ("Scripting.FileSystemObject"):

When you use JScript to read and write local files, you use the Scripting.FileSystemObject control.
IE, by default, is not allowed to run ActiveX controls that are not marked for safe execution of scripts.
So when you execute the downlink code:
FSO = new ActiveXObject ("Scripting.FileSystemObject");
Throws a "Automation server cannot create an object" exception.

The solution is:
IE-> Internet Options-> Security-> Custom Level-> ActiveX controls and Plug-ins-> Initialize and script ActiveX controls that are not marked as safe to execute script (unsafe)-> enable

Attention:

Enabling this option is only available for debugging local code and must be remembered before accessing other web sites.
Otherwise malicious script will be through IE has read, write, traverse your local files and so on all the permissions!!!

I hope this article will help you with your JavaScript programming.

Related Article

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.