diff --git a/appexemplo_v1.0/app/control/forms/fields/exe_upload_img.php b/appexemplo_v1.0/app/control/forms/fields/exe_upload_img.php index dbf29380..0277d6b5 100644 --- a/appexemplo_v1.0/app/control/forms/fields/exe_upload_img.php +++ b/appexemplo_v1.0/app/control/forms/fields/exe_upload_img.php @@ -67,7 +67,7 @@ public function __construct() $btnScreenshot->class = 'btn btn-primary btn-sm'; $btnScreenshot->setLabel('Salvar'); $btnScreenshot->setImage('fa:camera'); - $btnScreenshot->addFunction("fd5WebCamCampiturar('".$idField."')"); + $btnScreenshot->addFunction("fd5VideoCampiturar('".$idField."')"); $divButton = new TElement('div'); $divButton->class = 'fd5DivVideoButton'; diff --git a/appexemplo_v1.0/app/lib/include/FormDin5WebCams.js b/appexemplo_v1.0/app/lib/include/FormDin5WebCams.js index 4ca0a6b2..1a586784 100644 --- a/appexemplo_v1.0/app/lib/include/FormDin5WebCams.js +++ b/appexemplo_v1.0/app/lib/include/FormDin5WebCams.js @@ -89,8 +89,7 @@ function fd5VideoStart(){ console.log(error); }); } - -function fd5WebCamCampiturar(id){ +function fd5VideoCampiturar(id){ let hiddenField = document.querySelector('#'+id); console.log(hiddenField); @@ -100,10 +99,11 @@ function fd5WebCamCampiturar(id){ var context = canvas.getContext('2d'); context.drawImage(video, 0, 0); + var nameFile = 'image' + Math.floor((Math.random() * 1000000) + 1) + '.png'; var link = document.createElement('a'); - link.download= 'foto.png'; - hiddenField.value = 'foto.png'; + link.download= nameFile; + hiddenField.value = nameFile; link.href = canvas.toDataURL(); link.textContent = 'Clique para baixar a imagem'; document.body.appendChild(link);