I get the picture through javascript, however I can not save it in a php variable
<?php
if (!isset($_SESSION['reglogin'])){
header("location: index.php");
}else{
if(isset($_POST['canvas'])){
$_SESSION['mfoto'] = $_POST['canvas'];
print_r($_SESSION['mfoto']);
}
?>
<input/ type="hidden" name="acao" id="acao" value="cad_selfie">
<div id="site_contents">
<div class="login-logo">
<img src='images/logotipo.jpg' width="100%" alt='GSR Money' title='' border='' onClick='' />
<img src='images/linhaCadastro_3.jpg' width="100%" alt='GSR Money' title='' border='' onClick='' />
</div>
<div id="loginpanelwrap_selfie">
<div class="loginheader">
<div>
<div>
<table>
<tr align="left">
<td style="color: red">*Tire uma foto com o documento aberto na mão</td>
</tr>
</table>
<video id="video" width="600" height="440" autoplay></video>
</div>
<div>
<button id="snap">Tirar Foto</button>
</div>
<div>
<canvas id="canvas" width="600" height="440"></canvas>
</div>
<table>
<tr>
<td> </td>
</tr>
</table>
<table>
<tr>
<td width="400px"> </td>
<td>
<input type="button" onclick="funcaoContinuar();" class="form_submit_continuar_azul" name="btncontinuar" id="btncontinuar" value="Continuar" />
</td>
</tr>
</table>
</div>
<div id="tenta" class="clear"></div>
<?php
if(isset($_SESSION['imgfoto'])){
print_r($_SESSION['imgfoto']);
}
?>
</div>
</div>
<script>
window.addEventListener("DOMContentLoaded", function() {
var canvas = document.getElementById("canvas"),
context = canvas.getContext("2d"),
video = document.getElementById("video"),
videoObj = {
"video": true
},
errBack = function(error) {
console.log("Video capture error: ", error.code);
};
if (navigator.getUserMedia) {
navigator.getUserMedia(videoObj, function(stream) {
video.src = stream;
video.play();
}, errBack);
} else if (navigator.webkitGetUserMedia) {
navigator.webkitGetUserMedia(videoObj, function(stream) {
video.src = window.webkitURL.createObjectURL(stream);
video.play();
}, errBack);
} else if (navigator.mozGetUserMedia) {
navigator.mozGetUserMedia(videoObj, function(stream) {
video.src = window.URL.createObjectURL(stream);
video.play();
}, errBack);
}
}, false);
document.getElementById("snap").addEventListener("click", function() {
canvas.getContext("2d").drawImage(video, 0, 0, 600, 440);
//alert(canvas.toDataURL());
});
function funcaoContinuar() {
document.frm_selfie.submit()
}
</script>
<form name="frm_selfie" id="frm_selfie" method="post">
<input/ type="hidden" name="acao" id="acao" value="cad_rg">
<!-- EU PRECISO SALVAR A IMAGEM DENTRO DESSE FORM PORQUE NA PRÓXIMA PÁGINA EU QUERO MOSTRAR A IMAGEM E NISSO O CLIENTE
FINALIZARÁ O CADASTRO E VOU SALVAR A IMAGEM NO BANCO MYSQL
-->
</form>
<?php
}
?>