ie下jpg轉base64編碼

function GetBase64_IE(photoFileName) {
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
//IE瀏覽器支持的創建方式
xmlHttp.open("GET", photoFileName, false);
//xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=x-user-defined");
xmlHttp.send(null);


var out = [];
//使用一段vbscript把二進制轉換成數組,BinaryToArray可以從網上搜到
var t = BinaryToArray(xmlHttp.responseBody).toArray();
try {
for (i = 0; i < t.length - 1; i++) {
//out.push(t.charCodeAt(i)&0xff);
out.push(t[i] & 0xff);
}
} catch (e) {
//this.DEBUG('loadBinaryResource: failednException:'+e);
};
//var arr = new Uint8Array(out);
var raw = String.fromCharCode.apply(null, out);


//delphiXe自帶Base64應該是Unicode的,所以暫不使用
var b64 = encode64(raw);

return b64;

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章