我正在開發面部識別系統。當我使用網絡攝像頭捕獲圖像時,網址會加載到表單中的文本框中。現在我希望表單提交和處理PHP,如果它是subimitted。這裏是我的形式當文本框內容發生變化時自動提交表格
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" enctype="multipart/form-data" id="frmsubmit">
<input type="text" class="form-control input-sm" id="imgsrc" name="imgsrc">
<input type="submit" value="AUTHENTICATE" class="btn btn-primary" data-loading-text="Loading..." name="send" id="submit">
</form>
和我的JavaScript
<script language="JavaScript">
webcam.set_api_url('present.php');
webcam.set_quality(100); // JPEG quality (1 - 100)
webcam.set_shutter_sound(true); // play shutter click sound
webcam.set_hook('onComplete', 'my_completion_handler');
function take_snapshot(){
// take snapshot and upload to server
document.getElementById('upload_results').innerHTML = '<h1>Uploading Image To Database...</h1>';
webcam.snap();
}
function my_completion_handler(msg) {
document.getElementById("imgsrc").value=msg;
// extract URL out of PHP output
if (msg.match(/(http\:\/\/\S+)/)) {
// show JPEG image in page
document.getElementById('upload_results').innerHTML ="<div class='alert alert-success fade in'> <i class='icon-remove close' data-dismiss='alert'></i> <strong>Success!</strong>Image Captured And Uploaded Successfully </div>";
document.getElementById('upload_img').innerHTML ="<img src="+msg+" class=\"images\">";
// reset camera for another shot
webcam.reset();
document.getElementById('frmsubmit').submit();
}
else {alert("PHP Error: " + msg);
}
}
</script>
和PHP代碼
if(isset ($_POST["send"]))
{如果你給形式的ID
我沒有看到表單標籤有ID =「frmsubmit」屬性! – Digvijay
對不起,我錯過了粘貼代碼 –