JQuery webcam Plugin - save image without PHP

前端 未结 4 1571
说谎
说谎 2021-01-07 11:45

I am using JQuery webcam plugin
Here is the home page
It seem very useful, but my problem is I don\'t know how to save image using asp.net (without using php).

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-07 11:52

    I don't know how to store image using instructions given in above link,but i have used other link webcamjs using this i was able to store image using asp.net server code

    in this link they also have given only in php but i have asp.net server code. You will have to download plugin from webcamjs and add this code...

    This will be div in which you will show webcam caputring area

    Take Picture

            

    And This script need to be added...

    
            
    

    Create new uploadimges.aspx named file and on page load of this file add this code....

    protected void Page_Load(object sender, EventArgs e)
            {
        System.Drawing.Image originalimg;
                    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);
                    }
                    originalimg = System.Drawing.Image.FromStream(log);
                    originalimg = originalimg.GetThumbnailImage(200, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
                    originalimg.Save(Server.MapPath("Images") + "\\" + strFile);
                    //Write jpg filename to be picked up by regex and displayed on flash html page.
                    log.Close();
                    originalimg.Dispose();
                    File.Delete(Server.MapPath(strFile));
                    Response.Write("../Images/" + strFile);
        }
            public bool ThumbnailCallback() { return false; }
    

    Here in this code give folder name in which you want to add image, i have given Images.

    Try this ,Happy Coding

提交回复
热议问题