如何使用JavaScript将文件移动到其他目录? [英] How can I move a file to other directory using JavaScript?

查看:82
本文介绍了如何使用JavaScript将文件移动到其他目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript新手。我需要使用JavaScript将文件移动到另一个目录。如何使用JavaScript简单地移动该文件?

I am new to JavaScript. I need to move a file to another directory using JavaScript. How can simply move that file with JavaScript?

我该如何解决这个问题?

How can I solve this?

我尝试了这个,但它没有用....

I tried this, but it didn't work....

<html>
<h2>Move file in JavaScript</h2>
<script language="javascript">
function moveFile(){
        var object = new ActiveXObject("Scripting.FileSystemObject");
        var file = object.GetFile("Table1.xml");
        file.Move("./Docus/");
        document.write("File is moved successfully");
}
</script>
<form>
<input type="Button" value="Move File" onClick='moveFile()'>
</form>
</html>

我怎么能这样做,任何人?

How can I do this, anyone?

推荐答案

试过这段代码,完美地运作:

Tried this code, working perfectly :

function moveFile(){
   var object = new ActiveXObject("Scripting.FileSystemObject");
   var file = object.GetFile("C:\\wamp\\www\\phptest.php");
   file.Move("C:\\wamp\\");
   document.write("File is moved successfully");
}

在你的代码中,问题似乎出现在文件路径./Docus/ 。
尝试输入绝对路径,然后检查。

In your code, issue seems to be in file path "./Docus/". Try to put absolute path and then check.

这篇关于如何使用JavaScript将文件移动到其他目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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