在js中利用Microsoft.XMLDOM进行二进制与base64互相转换代码

来源:互联网 发布:淘宝保健品店铺介绍 编辑:程序博客网 时间:2024/05/08 17:36



function base64OrBin(obj) {//设置base64,就输出bin,相反,设置bin就输出base64,会自动判别
    var xml = new ActiveXObject('Microsoft.XMLDOM');
    var node = xml.createElement("obj");
    node.dataType = "bin.base64";
    obj = 'string' == typeof obj ? (node.text = obj, node.nodeTypedValue) : (node.nodeTypedValue = obj, node.text);
    node = xml = null;
    return obj;
}


可以结合ado.stream读取二进制文件或是储存


原创粉丝点击