neha arora
neha arora

Reputation: 27

internet explorer: download a binary file using ajax 'GET' call

hi i am new to ajax and js. i have to silently download(no prompt) a binary file (acyually .zip) and save it on my local machine. i am able to get the data from server:

var xmlhttp = new XMLHttpRequest();

xmlhttp.open('GET', downloadURL , true);
xmlhttp.responseType = 'arraybuffer';
xmlhttp.onload = function() {
    var typedData = new Uint8Array(xmlhttp.response),
    alert(typedData );      
    }
xmlhttp.send(null);

I now need to save this data on my local machine to a specified path. i am not able to do that. also i have to run this on internet explorer 10.

new thought: but yes c++ allows you to create a file. so if somehow i pass the data i have from js to c++ code, probably i can achieve what i want :) [PS: simpler way would have been to download it in c++ code but i cant do that because of the authentication mechanism i use]

Upvotes: 0

Views: 856

Answers (1)

Shriike
Shriike

Reputation: 1341

This is impossible for security reasons. Javascript cannot directly save a file to the local machine. That would be a feature hackers would love to take advantage of.

Upvotes: 4

Related Questions