2011-09-27 52 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