首页 新闻 会员 周边 捐助

关于javascript xml bin.base64存储文件到数据库

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