• 上传图片


     var adostream = new ActiveXObject("ADODB.Stream");
                    adostream.Type = 1;
                    adostream.Mode = 3;
                    adostream.Open();
                    adostream.LoadFromFile("D:ScanRaw.jpg");
                    if (adostream.Size > 1024 * 1024 * 10) {
                        delete adostream;
                        return false;
                    }
                    // var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
                    var xmlhttp = xmlhttp = createXMLHttp();
                    xmlhttp.Open("POST", "UploadIdCardjpg.aspx?filename=" + escape("<%=RandomNum%>"), false);
                    xmlhttp.Send(adostream.Read(adostream.Size));
                    var receiveValue = xmlhttp.responseText;
                    adostream.Close();
                    delete adostream;
                    delete xmlhttp;

     protected void Page_Load(object sender, EventArgs e)         {        

         string newstrTime = DateTime.Now.ToString("HH") + "_";        

         string _newfilepath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "\" + DateTime.Now.ToString("yyyy") + "\" + DateTime.Now.ToString("yyyyMM");        

        // string newstrfilepath = System.Configuration.ConfigurationManager.AppSettings["vWGFilePath"] + "/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("yyyyMM") + "/";      

           string filename = Request.QueryString["filename"];    

             string newstrImageName = filename + ".jpg";      

           HttpContext context = HttpContext.Current;       

          context.Response.ContentType = "text/plain";       

          if (!System.IO.Directory.Exists(System.IO.Path.Combine(context.Request.PhysicalApplicationPath, _newfilepath)))             {   

                  System.IO.Directory.CreateDirectory(System.IO.Path.Combine(context.Request.PhysicalApplicationPath, _newfilepath));    

             }       

              //利用新传来的路径实例化一个FileStream对象      

           byte[] sf = new byte[Request.InputStream.Length];  //定义byte型数组    

             Request.InputStream.Read(sf, 0, sf.Length);           

      FileStream newfstream = File.Create(_newfilepath + "\" + newstrTime + newstrImageName, sf.Length);      

           try             {          

           newfstream.Write(sf, 0, sf.Length);   //二进制转换成文件         

        }             catch (Exception ex)             {      

               //log.Error("文件保存:" + ex.Message);        

         }             finally             {            

         newfstream.Close();             

        Request.InputStream.Close();

                }

            }

     <add key="vWGFilePath" value="/T/CRJTSZX" />
     <add key="SaveFilePath" value="D:TCRJTSZX" />

                string _newfilepath = System.Configuration.ConfigurationManager.AppSettings["SaveFilePath"] + "\" + DateTime.Now.ToString("yyyy") + "\" + DateTime.Now.ToString("yyyyMM");             string newstrfilepath = System.Configuration.ConfigurationManager.AppSettings["vWGFilePath"] + "/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("yyyyMM") + "/";             if (!_newfilepath.EndsWith("\"))             {                 _newfilepath = _newfilepath + "\";             }             Hzjg.Site.Common.Message msg = new Hzjg.Site.Common.Message();             try             {                 FileInfo _file = new FileInfo(postFile.FileName);                 string sdata = DateTime.Now.ToString("yyyyMM");                 string t = DateTime.Now.ToString("yyyyMMddHHmmss");                 Random dm = new Random();                 long lip = dm.Next(10000);                 string ext = _file.Extension.ToLower();                 string sguid = t + "_" + lip;                 if (!Directory.Exists(_newfilepath))                 {                     Directory.CreateDirectory(_newfilepath);                 }                 string filePath = _newfilepath + sguid + ext;                 int iCount = 0;                 while (File.Exists(filePath))                 {                     sguid = t + "_" + lip + "_" + (++iCount);                     filePath = _newfilepath + sguid + ext;                     if (iCount > 100) break;                 }                 postFile.SaveAs(filePath);

                    newstrfilepath = newstrfilepath.Replace("Temp", "userfiles") + "/" + sguid + ext;                 msg.State = Hzjg.Site.Common.MessageState.Success;                 msg.Msg = newstrfilepath;

  • 相关阅读:
    乔治·奥威尔的六条有效写作的规则
    读书:《个人形成论》 Carl R. Rogers
    想想体制性的生存法则
    每一个山峰都建立在同一座山上
    读书笔记:这些道理没有人告诉过你(二)
    举国的不仅仅是运动员
    参加了一个社会化营销策划比赛整理一下参考资料
    读书:《个人形成论》2 Carl R. Rogers
    前端避坑指南丨辛辛苦苦开发的 APP 竟然被判定为简单网页打包?
    Entify Framework 4.1[问题集] 一个实体的双向依赖引起的错误
  • 原文地址:https://www.cnblogs.com/wyBlog117/p/4543805.html
Copyright © 2020-2023  润新知