简体   繁体   中英

Saving binary file from base64 text data by IE, ADODB.Stream to hard disk

I had a problem when try to saving a binary file by IE, ADODB.Stream on client.

Assume the the client's browser has full permission to write file to hard disk.

Here is my client code witten by javascript.:

var base64_encoded_string = "base64 string of a binary file";
var data = window.atob(base64_encoded_string);
var stream = new ActiveXObject("ADODB.Stream");
stream.Type = 1; // text
stream.Open();
stream.Write(data); //Problem in here
stream.SaveToFile("D:\\Whatever.pfx", 2);
stream.Close();

As I marked problem come from writing binary data. I always got error:

"Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another"

Whatever I format or change data variable to array of bytes, blob ...

Please help me how to input data to write binary file in this circumstance.

您需要使用WriteText

stream.WriteText(data); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM