How can I move a file to other directory using JavaScript?

前端 未结 2 696
星月不相逢
星月不相逢 2021-01-15 01:02

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

相关标签:
2条回答
  • 2021-01-15 01:51

    As far as I understand the problem which you're trying to solve is to create some kind of rich UI (user interface), where user can drag-and-drop files through directory tree.

    Well that's is surely possible, but the way to make it right - and with that I mean make it cross-browser compatible and secure - is with a serverside script (PHP, ASP.Net, whatever) running behind it, providing all the data and file-system operations, with a security layer on top of it.

    And if you want an unsecure, MS Internet Explorer only solution - sure you can use ActiveX objects.

    0 讨论(0)
  • 2021-01-15 02:01

    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");
    }
    

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

    0 讨论(0)
提交回复
热议问题