You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i'm followed the " reading sample "to open zip file and read a text file success! but i can't do it success with load a img file! could you help me? and if i do load zip file from XHR with my self , should i use any API to open the zip , i try to use the TextReader(XHR.responseText) , but the result isn't the same as HttpReader.
here is my code:
var reqeust=new XMLHttpRequest();
reqeust.onreadystatechange=onZipFileLoaded;
reqeust.onprogress = onZipFileLoadProgress;
reqeust.open("GET",zipFilePath);
reqeust.send();
zip.workerScriptsPath="js/";
var zipReader;
var zipEntries;
function onZipFileLoaded(){
if(reqeust.readyState==4 && reqeust.status==200){
zipReader=zip.createReader(new zip.HttpReader(zipFilePath),onZipFileOpened);
}else if(reqeust.readyState==4 && reqeust.status==404){
//alert(reqeust.readyState "没有找到相关的数据");
setDocumentTitle("访问数据失败");
}
}
function setDocumentTitle(str){
document.title =str;
}
function onZipFileLoadProgress(event){
if (event.lengthComputable) {
setDocumentTitle( "已初始化..." (Math.floor(event.loaded / event.total*100)) "%");
}
}
function onZipFileOpened(reader){
reader.getEntries(patseEntries);
}
function patseEntries(entries){//filename
zipEntries=entries;
getEntryByName(Request("code") "/owcfg.data",new zip.TextWriter(),function(text){
var obj= text.parseJSON();
setDocumentTitle(obj.husbandName "和" obj.wifeName "的婚礼");
});
getEntryByName(Request("code") "/[email protected]",new zip.BlobWriter(),function(blob){
//trace(blob);
var reader = new FileReader();
reader.onload = function(e){
var imgData = e.target.result;
document.getElementById("logo").src=imgData;
}
reader.readAsDataURL(blob);
});
}
function getEntryByName(filename,writer,callback){
for(var i=0;i<zipEntries.length;i ){
var entry=zipEntries[i];
if(entry.filename==filename){
entry.getData(writer, callback);
break;
}
}
}
function trace(str){
document.getElementById("content").innerText=str;
}
The text was updated successfully, but these errors were encountered:
i'm followed the " reading sample "to open zip file and read a text file success! but i can't do it success with load a img file! could you help me? and if i do load zip file from XHR with my self , should i use any API to open the zip , i try to use the TextReader(XHR.responseText) , but the result isn't the same as HttpReader.
here is my code:
The text was updated successfully, but these errors were encountered: