JQuery的摄像头插件 - 保存图像,而不PHP [英] JQuery webcam Plugin - save image without PHP

查看:372
本文介绍了JQuery的摄像头插件 - 保存图像,而不PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JQuery摄像头插件


这里是主页

这似乎是非常有用的,但我的问题是我不知道如何使用asp.net(不使用PHP)来保存图像。没有人有任何建议?

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). Does anyone have any suggest?

推荐答案

我不知道如何使用上面的链接作出批示,要求店面形象,但我已经使用的其他环节的 webcamjs 使用这个我能使用asp.net服务器code存储图像

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

在这个环节上,他们也只给出了在PHP,但我有asp.net服务器code。
你将不得不从webcamjs插件下载并添加此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...

这将div的在其中会显示摄像头caputring区

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

<div>
                    <table border="0" cellpadding="0" cellspacing="5">
                        <tr>
                            <td valign="top">
                                <h3 id="tk_pic" style="margin-left: 30px;">
                                    Take Picture</h3>
                                <div id="pic_area">
                                    <table id="Table2" runat="server">
                                        <tr>
                                            <td>

                                                <script type="text/javascript" language="JavaScript">
                                                    document.write(webcam.get_html(320, 240));
                                                </script>

                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <input type="button" value="Configure..." onclick="webcam.configure()">
                                                &nbsp;&nbsp;
                                                <input type="button" value="Capture" onclick="webcam.freeze()">
                                                &nbsp;&nbsp;
                                                <input type="button" value="Upload"  onclick="do_upload()">
                                                &nbsp;&nbsp;
                                                <input type="button" value="Reset"  onclick="webcam.reset()">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <div id="upload_results" runat="server" style="background-color: #eee;">
                                                </div>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>

和该脚本需要添加...

And This script need to be added...

<script type="text/javascript" src="webcam.js"></script>
        <script type="text/javascript">

      webcam.set_api_url('../uploadimges.aspx');
            webcam.set_quality(90); // JPEG quality (1 - 100)
            webcam.set_shutter_sound(true); // play shutter click sound

                webcam.set_hook('onComplete', 'my_completion_handler');

                function do_upload() {
                    // upload to server
                     document.getElementById('<%=upload_results.ClientID%>').innerHTML  = '<h1>Uploading...</h1>';
                    webcam.upload();
                }

                function my_completion_handler(msg) {
                    // extract URL 
                    if (msg.match(/(http\:\/\/\S+)/)) {
                        var image_url = RegExp.$1;
                        // show JPEG image in page
                        document.getElementById('<%=upload_results.ClientID%>').innerHTML =
                        '<h1>Upload Successful!</h1>' +
                        '<img src="' + image_url + '">';

                        // reset camera for another shot
                        webcam.reset();
                    }
                    else alert("Error: " + msg);
                }

            </script>

新建uploadimges.aspx命名的文件并在此文件的页面加载添加此code ....

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; }

下面这个code给要在其中添加图像文件夹的名字,我已经给了图片

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

试试这个,快乐编码

这篇关于JQuery的摄像头插件 - 保存图像,而不PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆