Save Image From Webrequest in C#

前端 未结 2 840
难免孤独
难免孤独 2021-01-23 14:47

I\'m using a jQuery webcam plugin to communicate with a webcam in my page and take a snapshot. The way it works is by communicating with a Flash helper. To save the picture it t

2条回答
  •  清歌不尽
    2021-01-23 15:44

    I Have Done That In This And It Works For Me.

    protected void Page_Load(object sender, EventArgs e)
        {
            string strFile = DateTime.Now.ToString("dd_MMM_yymmss") + ".jpg";
          FileStream log = new FileStream(Server.MapPath(strFile),
           FileMode.OpenOrCreate);
            byte[] buffer = new byte[1024];
            int c;
            while ((c = Request.InputStream.Read(buffer, 0, buffer.Length)) > 0)
            {
                log.Write(buffer, 0, c);
            }
           //Write jpg filename to be picked up by regex and displayed on flash html page.
            Response.Write(strFile);
            log.Close();
    
        }
    

提交回复
热议问题