我目前正在制作HTA应用程序,我需要将Base64编码的ZIP存档保存到文件中。
var stream = new ActiveXObject('ADODB.Stream');
stream.Type = 1;
stream.Open();
stream.Write(atob(data));
stream.SaveToFile('dump.zip');
stream.Close();
此代码在stream.Write(data)上抛出错误Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
VBScript有一些解决方案,但我试图在javascript上创建它。
答案 0 :(得分:0)
感谢this帖子
var stream = new ActiveXObject('ADODB.Stream');
stream.Type = 2; //Stream type - text data o_0
stream.Charset = "windows-1251"; //windows-1252 works too
stream.Write(atob(data));
stream.SaveToFile('dump.zip');
stream.Close();
我仍然不明白为什么我必须将二进制数据保存为文本,但它可以工作。