Copy a file with JavaScript

0

Good!

I have a problem and I can not do something as simple as copying a file from a source to a destination , all locally using Javascript . p>

How can I do it? I found an example like:

myObject = new ActiveXObject("Scripting.FileSystemObject");
f = myObject.file.copy("c:\test.txt", "c:\mytest.txt");

But I need it to work in Chrome .... Any help? Thank you very much:)

    
asked by VGimenez 27.11.2016 в 11:13
source

2 answers

2

You can not . Web browsers (modern) do not allow javascript inside a web page to manipulate the computer's file system.

You can use plugins and extensions and activeX and other trivia, but there is no reliable way to work in all major browsers today.

(Note that it is possible to copy files using javascript but out of a web browser , using the file system module of , see for example this question )

    
answered by 28.11.2016 в 10:42
0

As you mention "Chrome" you mean to do it in a browser, that is not possible, in a browser you can only manipulate inside the browser, you can not manipulate it, at least using only that medium. This is for security, IE has the activeX in its browsers, which make it possible to give it that functionality, It's the only way to do it directly.

I wanted to do something similar, but what I had to do is create a desktop application that manipulates the desktop, and embed a local web server, and my application from the web, connects to the local server and makes the manipulation. It is the only way, delegating the function to another desktop project if you can manipulate it.

Greetings

    
answered by 20.02.2017 в 22:23