Javascript 如何从zip文件的url保存字节数组(xmlhttprequest.responseBody)并将其保存到本地?
我想使用Javascript 如何从zip文件的url保存字节数组(xmlhttprequest.responseBody)并将其保存到本地?,javascript,internet-explorer-8,Javascript,Internet Explorer 8,我想使用XMLHttpRequest.responseBody从url下载一个zip文件作为二进制数组,然后将其另存为文件。我该怎么做 我正在使用IE 8,直到收到xmlhttprequest.ResponseBy并将其转换为文本格式为止 那又怎样呢?如何将这些字节数组保存为文件 我对javascript和php非常陌生 function httpPost1(theUrl,param) { var xmlHttp = null; xmlHttp = new XMLHttpReque
XMLHttpRequest.responseBody
从url下载一个zip文件作为二进制数组,然后将其另存为文件。我该怎么做
我正在使用IE 8,直到收到xmlhttprequest.ResponseBy
并将其转换为文本格式为止
那又怎样呢?如何将这些字节数组保存为文件
我对javascript和php非常陌生
function httpPost1(theUrl,param)
{
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", theUrl+"?"+param, true);
xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Accept-Charset", "x-user-defined");
xmlHttp.onreadystatechange =function(){
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
// convert to string format from resonse
var fileContents = convertResponseBodyToText(xmlHttp.responseBody);
var bresults =[]; // convert to sring response to array of integers
for (var i=0; i<fileContents.length; i++)
{
bresults[i] =fileContents.charCodeAt(i) & 0xff
}
// how will i save the array as file?
}
}
}
xmlHttp.send();
}
函数httpPost1(URL,参数)
{
var xmlHttp=null;
xmlHttp=新的XMLHttpRequest();
open(“POST”,theUrl+“?”+参数,true);
setRequestHeader(“内容类型”,“应用程序/x-www-form-urlencoded”);
setRequestHeader(“接受字符集”,“x-用户定义”);
xmlHttp.onreadystatechange=函数(){
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
//从resonse转换为字符串格式
var fileContents=convertResponseBodyToText(xmlHttp.responseBody);
var bresults=[];//转换为对整数数组的sring响应
对于(var i=0;我为什么不简单地让用户下载文件?这里的情况完全不同。下载URL是客户端LAN中的本地系统的URL。因此,一旦我使用xhr接收到二进制数据,我想将其保存在服务器系统(使用jscript)或者直接将二进制数据上传到PHP脚本,该脚本可以将其保存为文件。