[已关闭问题]
关闭于 2008-02-04 02:05
读取文件保存到xml中,然后发送到后台保存 <BR>l_node6.dataType = "bin.base64"; <BR>var ado_stream = new ActiveXObject("ADODB.Stream"); <BR>ado_stream.Type = 1; // 1=adTypeBinary <BR>ado_stream.Open(); <BR>ado_stream.LoadFromFile(filename); <BR>l_node6.nodeTypedValue = ado_stream.Read(-1); // -1=adReadAll <BR>ado_stream.Close(); <BR>将文件读取成二进制然后64编码。组成xml利用xmlhttp发送xml串到后台 <BR>我的后台为c#,然后用 Convert.FromBase64String来解析数据的时候提示 <BR>Base-64 字符数组的无效长度。 <BR>请高手帮助!谢谢! <BR><BR><BR>一下是代码 <BR><BR>//保存上传的文件 <BR> function SaveFiles() <BR> { <BR>// create XML document with default header and primary node <BR>//var strXmlParamString = " <root> "; <BR>var xml_dom = new ActiveXObject("MSXML2.DOMDocument"); <BR>xml_dom.loadXML(' <?xml version="1.0" ?> <root/> '); <BR><BR>for (var i = 0; i < _fileList.length; ++ i) <BR> { <BR>var filename = _fileList[i]; <BR>if(filename.length > 0) <BR>{ <BR>var sarray = new Array(); <BR>sarray = filename.split('\\'); <BR>var name = sarray[sarray.length-1]; <BR>var names = new Array(); <BR>names = name.split('.'); <BR>var filetype = names[1] <BR>//strXmlParamString += " <file> "; <BR>//增加一个图片节点 <BR>var l_node1 = xml_dom.createElement("file"); <BR> xml_dom.documentElement.appendChild(l_node1); <BR> <BR>var index = i + 1; <BR>//主键 <BR>var l_node2 = xml_dom.createElement("SYFC_ID"); <BR>l_node2.text = _syfc_id; <BR>l_node1.appendChild(l_node2); <BR>alert(xml_dom.xml); <BR>//strXmlParamString +=" <SYFC_ID> " + _syfc_id + " </SYFC_ID> "; <BR>//图片类型 <BR>var l_node3 = xml_dom.createElement("filetype"); <BR>l_node3.text = filetype; <BR>l_node1.appendChild(l_node3); <BR><BR>//图片标题 <BR>var l_node4 = xml_dom.createElement("fileTitle"); <BR>var fileTitle = _getFileTitle(index); <BR>l_node4.text = fileTitle; &l