I have the following code to create a file from Base64.
var byteCharacters =atob(content);
var byteNumbers = new Array(byteCharacters.length);
for (var i = 0; i < byteCharacters.length; i++) {
byteNumbers[i] = byteCharacters.charCodeAt(i);
}
var byteArray = new Uint8Array(byteNumbers);
var blob = new Blob([byteArray]);
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
window.navigator.msSaveOrOpenBlob(blob, 'msSaveBlob_testFile.docx');
The problem is that when I execute the msSaveOrOpenBlob it ask the user for downloading/saving of file, what I want is to automatically save it to user c drive.
I think this can be done using ActiveX in IE but even when I used ActiveX to save docx file although it saved the file but it says file is corrupted, but for simple txt file it works fine.
var FileOpener = new ActiveXObject("Scripting.FileSystemObject");
var FilePointer = FileOpener.OpenTextFile("C:\taqi.docx", 2, true);
FilePointer.WriteLine("some text");
FilePointer.Close();
even writing simple string to docx file, give me error of invalid file. But if I open the same docx file in notepad than I can see the text.
Now my question is how can I use the blob object to create file silently. the file can be (txt,docx,ppt,pdf)
Any help will be appreciated.
Thanks