WEB开发网
开发学院网页设计JavaScript Jquery基于ActiveX的批量上传 阅读

Jquery基于ActiveX的批量上传

 2010-01-08 00:00:00 来源:WEB开发网   
核心提示: 服务器端主要代码:#regionPage_LoadprotectedvoidPage_Load(objectsender,EventArgse){StreamphotoStream=Request.InputStream;XmlDocumentdoc=newXmlDocument();if(Re

服务器端主要代码:

#region Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            Stream photoStream = Request.InputStream;
            XmlDocument doc = new XmlDocument();
            if (Request.InputStream != null)
            {
                //byte[] _tmpData = new byte[photoStream.Length];
                //photoStream.Read(_tmpData, 0, Convert.ToInt32(photoStream.Length));
                //string request1 = System.Text.Encoding.UTF8.GetString(_tmpData); 

                doc.Load(photoStream);
                XmlNode nod = doc.DocumentElement.SelectSingleNode("path");
                Paths = nod.InnerText;
                nod = doc.DocumentElement.SelectSingleNode("fpath");
                string fpath = nod.InnerText;
                nod = doc.DocumentElement.SelectSingleNode("leave");
                string leaving = nod.InnerText;
                nod = doc.DocumentElement.SelectSingleNode("istj");
                string istj = nod.InnerText;
                string photoXML = doc.DocumentElement.SelectSingleNode("photo").InnerText;
                byte[] photo = Convert.FromBase64String(photoXML);

                //去除xml中的多余标签和属性,转化为stream
                MemoryStream stream = new MemoryStream();
                XmlDocument docphoto = new XmlDocument();
                char[] str = photoXML.ToCharArray();
                for (int i = 0; i < photo.Length; i++)
                {
                    stream.WriteByte(photo[i]);
                }
                docphoto.Save(stream);

                if (!string.IsNullOrEmpty(Paths))
                {
                    //存入cookie
                    HttpCookie cookie = Request.Cookies["Path"];
                    if (cookie == null)
                    {
                        cookie = new HttpCookie("Path");
                    }
                    cookie["path"] = fpath;
                    cookie["istj"] = istj;
                    cookie.Expires = DateTime.Now.AddDays(100d);
                    Response.Cookies.Add(cookie);
                    UploadPh(Paths, leaving, istj, stream);//在此方法处理你的上传
                }
            }
        }
#endregion

目前此方法有三大问题:

1.不同的浏览器安全级别略有区别,activex经常会弹出提示,影响用户体验,有的还需要用户设置本站点为信任站点。

2.除IE外别的浏览器无法使用

3.IE有一个补丁对ADODB.Stream进行了限制使用,如果你一直开了自动更新或打了这个补丁,会弹出js错误:automation无法在服务器创建。其实就是ADODB.Stream无法创建对象造成的。

解决方法:打开注册表编辑器

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\

把{00000566-0000-0010-8000-00AA006D2EA4} 项删除或修改键值为任意值(除了400),这样你的ADODB.Stream就可以创建成功了。

上一页  1 2 3 4 5 6 

Tags:Jquery 基于 ActiveX

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接