Reputation: 12728
I have two servers, Server1 & Server2. I want to copy a file from Server1 to Server2 with JavaScript. Is this possible? If so, how? For example, last week I used "wget" command for this action. Now I want to handle it with JS.
Upvotes: 0
Views: 131
Reputation: 35822
Nope. You can't access disk from JavaScript. Just for a moment think of security problems it can bring with itself. I simply create a web page, and when you visit it, I upload all the images of your girlfriend and publish them (just kidding, but that's the security problem it poses).
However, JavaScript can access files on some scenarios:
<input type='file' />
elementHowever, if you want, you can use Node.js to do that. However, this is a server-side stuff.
Upvotes: 0
Reputation: 1507
i don't know the full specifications for the task at hand, but you could look into using Node.js to assist with your issue. here's a quick repo that might help repo or you could use this snippet i took from similar post:
var http = require('http');
var fs = require('fs');
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/',
{'host': 'www.google.com'});
request.end();
out = fs.createWriteStream('out');
request.on('response', function (response) {
response.setEncoding('utf8');
response.on('data', function (chunk) {
out.write(chunk);
});
});
i hope this helps, and here's the original post
Upvotes: 3