使用javascript复制/替换/删除文件 [英] Copy/Replace/Delete file using javascript

查看:48
本文介绍了使用javascript复制/替换/删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想通过javascript将文件从一个位置复制到其他位置。

我尝试使用以下解决方案:< br $>




函数副本()

{

var myObject,newpath;

myObject = new ActiveXObject(Scripting.FileSystemObject);

myObject.CopyFile(c:\\test.txt,c:\\tmp \\ myTest.txt);

}



但ActiveXObject不适用于mozila和chrome。



有没有其他方法可以适用于所有浏览器。



plz help。

Hi,

I want to copy file from one location to other location through javascript.
I tried with below solution :


function copy()
{
var myObject, newpath;
myObject = new ActiveXObject("Scripting.FileSystemObject");
myObject.CopyFile ("c:\\test.txt", "c:\\tmp\\myTest.txt");
}

But ActiveXObject is not working for mozila & chrome.

Is there any other way to do this which can be applicable to all browsers .

plz help .

推荐答案

即使在IE上也不再支持ActiveX技术......因为IE9默认是关闭的,IE11甚​​至不允许你使用它们(Edge甚至无法识别它们)...所以使用它们只会帮助你较旧的IE版本...



您在这里尝试做的事情存在一个主要问题...您的网页(出于安全原因)在我们所称的内部运行'sandbox',一个与操作系统分离的虚拟环境...这个沙箱不能对连接到它的存储进行任何IO操作......

想象一下你自己能够创建一个网页可以自由地读/写你的磁盘 - 任何黑客的梦想......



所以你必须考虑/检查你真正的目标/需求并尝试在没有任何这样的IO的情况下解决它们......



如果毕竟你得出结论,没有IO就不能这样做,你应该考虑学习关于Java和Silverlight作为选项......
ActiveX technology not supported anymore even on IE...since IE9 it is off by default and IE11 does not even let you use them (Edge can't even recognize them)...So using them will help you only on older IE versions...

There is a major problem with what you trying to do here...Your web page (for security reasons) runs inside what we call 'sandbox', a virtual environment separated from the OS...This sandbox is NOT capable of any IO operations on the storage connected to it...
Imagine yourself one was able to create a web page that can freely read/write your disks - a wet dream of any hacker...

So you have to consider/check your really goals/needs and try to solve them without any such IO...

If after all, you came to the conclusion, that you can not do it without IO, you should consider to learn about Java and Silverlight as options...


这篇关于使用javascript复制/替换/删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆