1

Im using the Jquery webcam plugin demonstrated in this link : http://www.xarg.org/project/jquery-webcam-plugin/ im trying to integrate it with Asp.net , so far the camera is showing and oncapture method is reached , however im having a problem with saving the captured image , the typical scenario is that when the on capture() is fired the webcam.save(“page”) would send an HTTP_RAW_DATA request to that “page” and then some code saves the captured image , unfortunately ,this is not happening :/ Here is the aspx content page that has the webcam code :

 <script type="text/javascript">
      jQuery(document).ready(function(){
     jQuery("#webcam").webcam({
             width: 320,
             height: 240,
             mode: "save",
             swffile: "Scripts/jscam_canvas_only.swf",
             onTick: function () { },
             onSave: function () { 
             },
             onCapture: function () { 
                 webcam.save("WebForm1.aspx");
             },
             debug: function () { },
             onLoad: function () {
             }
         }); 
     });
 </script>

<p style="width:360px;text-align:center;font-size:12px"> 
   <a href="javascript:webcam.capture();void(0);">Take a picture instantly</a>
</p>    

The WebForm1.aspx is a content page I added to handle the request and I only added some code that is said to work in this link :

Save Image From Webrequest in C# and added

it to the code behind :

   public partial class WebForm1 : System.Web.UI.Page
    {
        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();
        }
    }

I think the issue might be that the request isn’t reached in the WebForm1.aspx .. Hope you guys can help me solving this ...

Community
  • 1
  • 1
user2310851
  • 11
  • 1
  • 3
  • It is better to use a handler, and not a page. After that do you debug your code, do you get any errors ? what the InputStream returns ? do you have debug it to see that ? – Aristos Feb 19 '14 at 20:28
  • Yes I have debugged the code and found the following : 1-the webForm1.aspx is not reached (can you provide any suggestion on the path of the page) 2- when I tried to make the page webcam.save(this) , and copied the code in webForm1.aspx pageload() to the calling page , the response was true but without any photo beenig saved . As you mentioned in your comment that adding a handler would work , can you please provide an example for that . – user2310851 Feb 23 '14 at 12:11

0 Answers0