2011-09-27 47 views
3

我目前正在实现照片快照功能,以允许用户通过网络摄像头设置他们的个人资料照片。为此,我使用jQuery Webcam PluginjQuery摄像头:保存模式导致:''错误:没有保存模式编译。“

在问题出现我想有用户点击“拍摄照片”,并在适当的位置保存到服务器的快照由用户图像API来检索。

看来这应该很容易做到,但由于某种原因,我遇到了问题,当按下按钮时,照片拍摄会正常进行,但由于我收到错误信息error: No save mode compiled in.

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

我试图从url中删除hashref变量,认为这可能导致图像数据以某种方式丢失/忽略,但这没有什么区别。任何人都可以看到我在这里做错了吗?我很确定我遵循了SO,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.

+0

你确定你正在使用的插件的最新版本?正如我在github上看到的那样,你提到的错误信息可能来自actionscript文件,但该行被推荐出来。如果检查失败,尝试检查jquerycam插件的其他forks https://github.com/infusion/jQuery-webcam/network/members(尝试例如lalop或nedforce分叉)。 – WTK

+0

感谢您的回复。我明确下载了最新版本(不止一次)。 – Dutchie432

回答

2

由于通常情况下,时间的限制,迫使我寻找替代品这一项目。我已经决定使用jpegCam Project。我在15分钟左右就完成了。简单!我不删除这个问题的唯一原因是未来这些知识的寻求者。

4

这是你的错误:

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.

+0

在这一点上,我必须说出你的名字。不过,感谢您为该主题做出贡献。 – Dutchie432

+0

我解决了我自己的问题:http://stackoverflow.com/questions/8267772/php-code-to-asp-net-c-sharp与您的问题的答案。大声笑,刚搬到jpegcam项目! –

+0

很高兴能为您提供帮助! :)快乐的编码。 – Dutchie432