php - jQuery 网络摄像头 : Save mode results in: '' error: No save mode compiled in.“

标签 php jquery webcam save

我目前正在实现照片快照功能,以允许用户通过网络摄像头设置他们的个人资料照片。为此,我使用 jQuery Webcam Plugin .

出现问题的原因是我想让用户单击“拍照”并将快照保存到服务器的适当位置以供用户图像 API 检索。

看起来这应该很容易做到,但由于某种原因我遇到了问题。当按下我的按钮时,照片捕捉正常,但保存没有正确执行,因为我收到错误 error: No save mode compiled in.

注意:我的保存 URL 包含一个 hash 变量,如 ?hash=XYZ123。这就是图像在 PHP 文件中的命名方式。

我试图从 url 中删除 hashref 变量,认为这可能导致图像数据以某种方式丢失/被忽略,但没有产生任何结果区别。谁能看到我在这里做错了什么?我很确定我遵循了文档以及位于此处的其他几篇文章,like this one .

截图

enter image description here

HTML

<div id="camera"></div> <!-- WebCam Live Display -->
<div id="wcStatus"></div> <!-- Debug Text Display -->

<button onclick="showWebcam();">Use Webcam Instead</button>

<!--This button is normally hidden until camera initialized, but for sake for demo-->
<button onclick="saveWebCam('XYZ123', '66');">Take a picture!</button>

JS

function showWebcam(){
    $("#camera").webcam({
        width: 320,
        height: 240,
        mode: "save",
        swffile: "/webcam/jscam_canvas_only.swf",
        debug: function(type, string) {
            $('#wcStatus').append(type + ": " + string + '<br /><br />');
        }     
    }); 
}
function saveWebCam(hash, id){
    var url = '/accountFiles/userImages/saveFromWebCam.php?hash=' + hash + '&ref=' + randomString(30);
    $('#wcStatus').append('Capturing: ' + url + '<br /><br />');
    webcam.capture();
    webcam.save(url);
}

PHP (saveFromWebCam.php)

<?php
    $destFile=$_REQUEST['hash'].'.jpg';
    $str = file_get_contents('php://input');
    file_put_contents($destFile, pack("H*", $str));     
?>

调试输出

notify: Camera started

Capturing: /accountFiles/userImages/saveFromWebCam.php

notify: Capturing started.

notify: Capturing finished.

error: No save mode compiled in.

最佳答案

这是你的错误:

swffile: "/webcam/jscam_canvas_only.swf",

应该是:

swffile: "js/jscam.swf",

引自 plugin webpage :

Points to the swf file of the Flash movie, which provides the webcam API. There are two swf files provided via the download archive: jscam.swf, which provides the full API and jscam_canvas_only.swf which have no embedded JPEG library (I embedded an adjusted JPGEncoder of the AS 3 corelib). Thereby, the file is only one third as large as the original.

关于php - jQuery 网络摄像头 : Save mode results in: '' error: No save mode compiled in.“,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7574223/

相关文章:

php - WordPress 忽略 Google App Engine PHP 上的 php.ini 设置

php - 使用 Lynx 在 CentOS 中运行 PHP 脚本

javascript - 如何使用单击功能删除对象中的数据?

javascript - Jquery 动画在关闭时出现两次

webcam - 无需安全问题即可访问闪光灯相机

cocoa - 如何从 CVImageBuffer 对象获取原始数据

java - 快速顶级服务器语言问题

php - PHP 中哪些值是 == NULL 但不是 === NULL?

Javascript——在循环中附加事件

c# - MS Lifecam API/网络摄像头按钮